Skip to content

Commit c5bef81

Browse files
LaunchDarklyReleaseBoteli-darklyLaunchDarklyCIhroederldbwoskow-ld
authored
prepare 5.10.1 release (#80)
* make the SDK a module * go mod tidy * fix bug where nil references are passed to persistent stores (#241) * remove support for indirect patch in stream * (5.0) complete test coverage for StreamProcessor * turn on coverage enforcement * fix logic for disabling db packages in coverage * move some internal code around for clearer organization * make sharedtest package internal, put public test helpers in new package * DRY * comment about data store tests * use latest public go-sdk-common, go-sdk-events, go-server-sdk-evaluation * remove unused polling logic for indirect/patch * update go-server-sdk-evaluation for data model changes * rm unnecessary type aliases that broke tests * fix test that used an overly sensitive equality test for a flag without variations * another test issue just like the previous commit * move more test helpers + misc fixes * test coverage * move data store test suite to subpackage * (5.0) fix bug in deleted item serialization * more test coverage * (5.0) interface cleanup: move data store types out of the way * dependency fixes * (5.0 - #7) updates for go-sdk-events API changes (#251) * (5.0) miscellaneous doc comment improvements * fix remaining godoc.org links * custom badge for pkg.go.dev * fix go.dev badge * add API docs link under Learn More * update dependencies * use test sandboxing to validate persistent store test failure modes * lint (use more general interface) * (5.0) specify proxy URL as a string * fix test * fix test * fix another test * 5.0.0-beta.1 * add client decorator that temporarily disables events * add scoped evaluation without events * remove all database subpackages (being moved to separate projects) (#256) * bump dependency versions and use ldlogtest package * lint * code example * move AllFlagsState-related types out of main package, add builder * rm obsolete references to HTTPOptions setter * minor Makefile fix * add clientSideAvailability to flag model * prepare 4.17.3 release (#36) * Releasing version 4.17.3 * (v5) use new client-side availability fields (#262) * ensure SDK non-test code has no module-only dependencies (#263) * 5.0.0-beta.6 * update redis repo name in comments * use optional int type * misc cleanup * update dependencies * add Go 1.15 CI job, use newer CircleCI images * typo * fix CI working directory * fix CI syntax * update readme to mention Go 1.15 * drop Go 1.13 build * use go-server-sdk-evaluation 1.0.0-beta.5 * (#2) add test data source (#266) * logging fixes/standardization * use non-beta packages, remove prerelease info * update release metadata * make Releaser create release tags with and without the "v" prefix * update to go-server-sdk-evaluation 1.0.1 for "less omitempty in flag JSON" fix (#272) * fix comment typos * serialize deleted item placeholders with full set of properties (#274) * update go-sdk-common to 2.0.1 * bump eventsource to 1.6.2 for ch95617 logging fix (#275) * use new jsonstream API (#277) * don't require path property in put event * update alpha dependencies * update for go-jsonstream API changes * build in Windows with Go 1.14 * bump go-sdk-common version to get user JSON parsing fix * remove excessive logging in ldfilewatch, add log message for reloading file * fail fast if SDK key has invalid characters, don't log the key * bump go-server-sdk-evaluation to get semver parsing fix * remove spurious logging of stream data * merge in alias event support * Removed the guides link * update to go-server-sdk-evaluation 1.1.2 for ch100737 fix * (#1) add unbounded segments interfaces, status provider, test suite (#288) * add unbounded segments interfaces, status provider, test suite * lint * add package comment * better component organization * rename cache time to poll interval, improve tests * rename segment keys to segment refs in unbounded segments API * fix naming some more * (#2) simplify(?) broadcasters using reflection (#289) * (#3) misc cleanup of data store test suites (#290) * (#4) finish adding support for big ("unbounded") segment in evaluations (#291) * (#5) change "unbounded segments" to "big segments" + use latest prerelease packages (#293) * fix segment ref string format in tests, update evaluator version * Point at exp-alloc feature branch of -common and -evaluation (#297) This just repoints the Go SDK at the exp-alloc feature branch of the go-sdk-common-private and go-server-sdk-evaluation-private repos. * expose big segment store wrapper component for reuse by Relay * lint * add DuplicateKeysHandling option to ldfiledata (#299) * use latest prerelease tags of go-sdk-common, go-server-sdk-evaluation * use prerelease tags of go-sdk-common and go-server-sdk-evaluation * update dependencies for JSON number parsing bugfix * use go-sdk-common 2.3.0, go-server-sdk-evaluation 1.3.0 * add big segments control methods for use by Relay * rm unused * update go-server-sdk-evaluation to 1.4.1 for big segments bugfix * use Releaser v2 config, add Go 1.16 CI * rename big segments to Big Segments * remove "non-module-build" CI test which can no longer be run * add CI job for Go 1.17; update linter & test coverage script * Update pull request template to correct CONTRIBUTING.md link * Remove reference to dep in CONTRIBUTING.md (#310) * SC-128558: Allow users to set custom headers on requests (#308) * Add ability to set custom headers via Headers method * better tests for simple proxy configuration (#311) * update evaluation engine to fix circular prereqs issue, add more eval error logging * add ServiceEndpoints to configuration API (#314) * fix setting of trackEvents/trackReason in AllFlagsState data when there's an experiment (#315) * Go SDK test service for use with the SDK test harness (#312) * fix AllFlagsState DetailsOnlyForTrackedFlags behavior * fix reason logic * enable big segments contract tests (#317) * implement tags * update doc comments to match latest spec * more doc comment updates * support new contract tests that need to set service endpoints independently * fix URI override logic * add VariationForAll/VariationForAllIndex in test data builder, deprecate old names * enforce 64-char limit on tag values * enable contract tests for polling mode * prevent data race on data source initialized property * fix linter command * update go-sdk-common to 2.5.1 for empty ldvalue.Raw fix * enable contract tests for SecureModeHash * Big Segment store tests should not expect an error value for "not found" condition * handle error gracefully if http.NewRequest fails Co-authored-by: Eli Bishop <[email protected]> Co-authored-by: LaunchDarklyCI <[email protected]> Co-authored-by: LaunchDarklyCI <[email protected]> Co-authored-by: Harpo Roeder <[email protected]> Co-authored-by: Ben Woskow <[email protected]> Co-authored-by: Sam Stokes <[email protected]> Co-authored-by: LaunchDarklyReleaseBot <[email protected]> Co-authored-by: Casey Waldren <[email protected]> Co-authored-by: Louis Chan <[email protected]>
1 parent dc9c1a4 commit c5bef81

File tree

11 files changed

+74
-12
lines changed

11 files changed

+74
-12
lines changed

internal/datasource/requestor.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package datasource
22

33
import (
4+
"fmt"
45
"io/ioutil"
56
"net/http"
67

@@ -83,6 +84,10 @@ func (r *requestorImpl) requestAll() ([]ldstoretypes.Collection, bool, error) {
8384
func (r *requestorImpl) makeRequest(resource string) ([]byte, bool, error) {
8485
req, reqErr := http.NewRequest("GET", endpoints.AddPath(r.baseURI, resource), nil)
8586
if reqErr != nil {
87+
reqErr = fmt.Errorf(
88+
"unable to create a poll request; this is not a network problem, most likely a bad base URI: %w",
89+
reqErr,
90+
)
8691
return nil, false, reqErr
8792
}
8893
url := req.URL.String()

internal/datasource/streaming_data_source.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,22 @@ func (sp *StreamProcessor) consumeStream(stream *es.Stream, closeWhenReady chan<
251251
}
252252

253253
func (sp *StreamProcessor) subscribe(closeWhenReady chan<- struct{}) {
254-
req, _ := http.NewRequest("GET", endpoints.AddPath(sp.streamURI, endpoints.StreamingRequestPath), nil)
254+
req, reqErr := http.NewRequest("GET", endpoints.AddPath(sp.streamURI, endpoints.StreamingRequestPath), nil)
255+
if reqErr != nil {
256+
sp.loggers.Errorf(
257+
"Unable to create a stream request; this is not a network problem, most likely a bad base URI: %s",
258+
reqErr,
259+
)
260+
sp.dataSourceUpdates.UpdateStatus(interfaces.DataSourceStateOff, interfaces.DataSourceErrorInfo{
261+
Kind: interfaces.DataSourceErrorKindUnknown,
262+
Message: reqErr.Error(),
263+
Time: time.Now(),
264+
})
265+
sp.logConnectionResult(false)
266+
close(closeWhenReady)
267+
return
268+
}
269+
255270
for k, vv := range sp.headers {
256271
req.Header[k] = vv
257272
}

internal/datasource/streaming_data_source_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,3 +565,26 @@ func TestStreamProcessorRestartsStreamIfStoreNeedsRefresh(t *testing.T) {
565565
})
566566
})
567567
}
568+
569+
func TestMalformedStreamBaseURI(t *testing.T) {
570+
mockLog := ldlogtest.NewMockLog()
571+
defer mockLog.DumpIfTestFailed(t)
572+
clientContext := internal.NewClientContextImpl(
573+
interfaces.BasicConfiguration{SDKKey: testSDKKey},
574+
sharedtest.TestHTTPConfig(),
575+
sharedtest.TestLoggingConfigWithLoggers(mockLog.Loggers),
576+
)
577+
withMockDataSourceUpdates(func(updates *sharedtest.MockDataSourceUpdates) {
578+
sp := NewStreamProcessor(clientContext, updates, ":/", briefDelay)
579+
defer sp.Close()
580+
581+
closeWhenReady := make(chan struct{})
582+
sp.Start(closeWhenReady)
583+
584+
status := updates.RequireStatusOf(t, interfaces.DataSourceStateOff)
585+
assert.Equal(t, interfaces.DataSourceErrorKindUnknown, status.LastError.Kind)
586+
<-closeWhenReady
587+
588+
mockLog.AssertMessageMatch(t, true, ldlog.Error, "Unable to create a stream request")
589+
})
590+
}

testhelpers/storetest/big_segment_store_test_suite.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,11 @@ func (s *BigSegmentStoreTestSuite) runMetadataTests(t testbox.TestingT) {
8282

8383
t.Run("no value", func(t testbox.TestingT) {
8484
s.withStoreAndEmptyData(t, func(store interfaces.BigSegmentStore) {
85-
_, err := store.GetMetadata()
86-
require.Error(t, err)
85+
meta, err := store.GetMetadata()
86+
// The Big Segment store should not return a database error in this case; it should return
87+
// a result with an unset (zero) LastUpToDate, meaning "the store has not been updated ever".
88+
assert.Equal(t, ldtime.UnixMillisecondTime(0), meta.LastUpToDate)
89+
assert.NoError(t, err)
8790
})
8891
})
8992
}

testhelpers/storetest/big_segment_store_test_suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (s *mockSegmentStore) GetMetadata() (interfaces.BigSegmentStoreMetadata, er
4848
return s.owner.overrideGetMetadata(s)
4949
}
5050
if s.metadata == nil {
51-
return interfaces.BigSegmentStoreMetadata{}, errors.New("not found")
51+
return interfaces.BigSegmentStoreMetadata{}, nil
5252
}
5353
return *s.metadata, nil
5454
}

testservice/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.14
44

55
require (
66
github.com/gorilla/mux v1.8.0
7-
gopkg.in/launchdarkly/go-sdk-common.v2 v2.4.0
7+
gopkg.in/launchdarkly/go-sdk-common.v2 v2.5.1
88
gopkg.in/launchdarkly/go-server-sdk.v5 v5.4.0
99
)
1010

testservice/go.sum

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ gopkg.in/launchdarkly/go-jsonstream.v1 v1.0.0/go.mod h1:YefdBjfITIP8D9BJLVbssFct
5757
gopkg.in/launchdarkly/go-jsonstream.v1 v1.0.1 h1:aZHvMDAS+M6/0sRMkDBQ8MyLGsTQrNgN5evu5e8UYpQ=
5858
gopkg.in/launchdarkly/go-jsonstream.v1 v1.0.1/go.mod h1:YefdBjfITIP8D9BJLVbssFctHkJnQXhv+TiRdTV0Jr4=
5959
gopkg.in/launchdarkly/go-sdk-common.v2 v2.2.1/go.mod h1:Fht0iTasUXh2xiDA8IJSmlSGbyQ1GNpmt97lXYz6+p8=
60-
gopkg.in/launchdarkly/go-sdk-common.v2 v2.4.0 h1:uA7it+cSIDIF4AhLoaLvQ5h9TxvSSVmn/CsJiAqrm4E=
6160
gopkg.in/launchdarkly/go-sdk-common.v2 v2.4.0/go.mod h1:P2+C6CHteys+lEDd6298QszCsMhjdYrfzBd6dg//CHA=
61+
gopkg.in/launchdarkly/go-sdk-common.v2 v2.5.1 h1:RqucG3hCU/GAupuEyVXXPf0Hz3F4InyhiFR2sfUbgBs=
62+
gopkg.in/launchdarkly/go-sdk-common.v2 v2.5.1/go.mod h1:P2+C6CHteys+lEDd6298QszCsMhjdYrfzBd6dg//CHA=
6263
gopkg.in/launchdarkly/go-sdk-events.v1 v1.1.1 h1:LfbZsHTPwjzhDbJ/IjYs0oc8rWcbyJM7nN+Ce4ZdUVM=
6364
gopkg.in/launchdarkly/go-sdk-events.v1 v1.1.1/go.mod h1:UETsxDtKpoDGUrwliXl1L7OG68zjOO0aagDI8OnvDRw=
6465
gopkg.in/launchdarkly/go-server-sdk-evaluation.v1 v1.5.0 h1:gA0F8n0sJ0K6LOLuyC28+O4garjdaU2T3m5mk1Fki8g=

testservice/sdk_client_entity.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ func (c *SDKClientEntity) DoCommand(params servicedef.CommandParams) (interface{
8989
case servicedef.CommandGetBigSegmentStoreStatus:
9090
bigSegmentsStatus := c.sdk.GetBigSegmentStoreStatusProvider().GetStatus()
9191
return servicedef.BigSegmentStoreStatusResponse(bigSegmentsStatus), nil
92+
case servicedef.CommandSecureModeHash:
93+
hash := c.sdk.SecureModeHash(params.SecureModeHash.User)
94+
return servicedef.SecureModeHashResponse{Result: hash}, nil
9295
default:
9396
return nil, BadRequestError{Message: fmt.Sprintf("unknown command %q", params.Command)}
9497
}

testservice/service.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var capabilities = []string{
2929
servicedef.CapabilityAllFlagsDetailsOnlyForTrackedFlags,
3030
servicedef.CapabilityAllFlagsWithReasons,
3131
servicedef.CapabilityBigSegments,
32+
servicedef.CapabilitySecureModeHash,
3233
servicedef.CapabilityServerSidePolling,
3334
servicedef.CapabilityServiceEndpoints,
3435
servicedef.CapabilityTags,

testservice/servicedef/command_params.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const (
1414
CommandAliasEvent = "aliasEvent"
1515
CommandFlushEvents = "flushEvents"
1616
CommandGetBigSegmentStoreStatus = "getBigSegmentStoreStatus"
17+
CommandSecureModeHash = "secureModeHash"
1718
)
1819

1920
type ValueType string
@@ -27,12 +28,13 @@ const (
2728
)
2829

2930
type CommandParams struct {
30-
Command string `json:"command"`
31-
Evaluate *EvaluateFlagParams `json:"evaluate,omitempty"`
32-
EvaluateAll *EvaluateAllFlagsParams `json:"evaluateAll,omitempty"`
33-
CustomEvent *CustomEventParams `json:"customEvent,omitempty"`
34-
IdentifyEvent *IdentifyEventParams `json:"identifyEvent,omitempty"`
35-
AliasEvent *AliasEventParams `json:"aliasEvent,omitempty"`
31+
Command string `json:"command"`
32+
Evaluate *EvaluateFlagParams `json:"evaluate,omitempty"`
33+
EvaluateAll *EvaluateAllFlagsParams `json:"evaluateAll,omitempty"`
34+
CustomEvent *CustomEventParams `json:"customEvent,omitempty"`
35+
IdentifyEvent *IdentifyEventParams `json:"identifyEvent,omitempty"`
36+
AliasEvent *AliasEventParams `json:"aliasEvent,omitempty"`
37+
SecureModeHash *SecureModeHashParams `json:"secureModeHash,omitempty"`
3638
}
3739

3840
type EvaluateFlagParams struct {
@@ -81,3 +83,11 @@ type BigSegmentStoreStatusResponse struct {
8183
Available bool `json:"available"`
8284
Stale bool `json:"stale"`
8385
}
86+
87+
type SecureModeHashParams struct {
88+
User lduser.User `json:"user"`
89+
}
90+
91+
type SecureModeHashResponse struct {
92+
Result string `json:"result"`
93+
}

0 commit comments

Comments
 (0)