Skip to content

Commit 9f28775

Browse files
Merge branch 'master' into pawel/fix_requester_despatcher
2 parents 29bb8ae + 02f4bbd commit 9f28775

File tree

4 files changed

+45
-30
lines changed

4 files changed

+45
-30
lines changed

CHANGELOG.MD

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
88
Changes that have landed but are not yet released.
99
- Support for running full feature tests with the SDK.
1010

11+
## [0.2.0] - September 11th, 2019
12+
This release of the SDK introduces Feature Management capabilities for running both Feature Rollouts as well as Feature Tests using Optimizely Feature Management.
13+
14+
### New Features
15+
- Introduces feature variable getters via `GetFeatureVariable*` for parameterizing your feature tests.
16+
- Introduces the `Track` API call for sending conversion events to Optimizely.
17+
- The `IsFeatureEnabled` API will now send impression events if there is a feature test attached to the feature being accessed.
18+
19+
### Breaking Changes
20+
- Vendored packages have been removed in favor of declaring dependencies and their versions using `go.mod`.
21+
1122
## [0.1.0-beta] - August 23rd, 2019
1223
This is the initial release of the SDK, which includes support for running Feature Rollouts using Optimizely Feature Management.
1324

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ module mymodule
9595
go 1.12
9696
9797
require (
98-
github.com/optimizely/go-sdk v0.1.0
98+
github.com/optimizely/go-sdk v0.2.0
9999
)
100100
```
101101

102102
If you are already using `go.mod` in your application you can run the following:
103103

104104
```
105-
go mod edit -require github.com/optimizely/go-sdk@v0.1.0
105+
go mod edit -require github.com/optimizely/go-sdk@v0.2.0
106106
```
107107

108108
NOTE:
@@ -247,3 +247,7 @@ License (BSD-3 Clause): https://github.com/google/uuid/blob/master/LICENSE
247247
testify
248248
Copyright (c) 2012-2018 Mat Ryer and Tyler Bunnell.
249249
License (MIT): https://github.com/stretchr/testify/blob/master/LICENSE
250+
251+
json-iterator
252+
Copyright (c) 2016 json-iterator
253+
License (MIT): https://github.com/json-iterator/go/blob/master/LICENSE

optimizely/config/polling_manager.go

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -53,42 +53,42 @@ type PollingProjectConfigManager struct {
5353
exeCtx utils.ExecutionCtx // context used for execution control
5454
}
5555

56-
func (cm *PollingProjectConfigManager) activate(initialPayload []byte, init bool) {
57-
58-
update := func() {
59-
var e error
60-
var code int
61-
var payload []byte
62-
if init && len(initialPayload) > 0 {
63-
payload = initialPayload
64-
} else {
65-
payload, code, e = cm.requester.Get()
66-
67-
if e != nil {
68-
cmLogger.Error(fmt.Sprintf("request returned with http code=%d", code), e)
69-
}
70-
}
71-
72-
projectConfig, err := datafileprojectconfig.NewDatafileProjectConfig(payload)
73-
if err != nil {
74-
cmLogger.Error("failed to create project config", err)
56+
// SyncConfig gets current datafile and updates projectConfig
57+
func (cm *PollingProjectConfigManager) SyncConfig(datafile []byte) {
58+
var e error
59+
var code int
60+
if len(datafile) == 0 {
61+
datafile, code, e = cm.requester.Get()
62+
63+
if e != nil {
64+
cmLogger.Error(fmt.Sprintf("request returned with http code=%d", code), e)
7565
}
66+
}
7667

77-
cm.configLock.Lock()
78-
cm.projectConfig = projectConfig
79-
cm.err = err
80-
cm.configLock.Unlock()
68+
projectConfig, err := datafileprojectconfig.NewDatafileProjectConfig(datafile)
69+
if err != nil {
70+
cmLogger.Error("failed to create project config", err)
8171
}
8272

73+
// TODO: Compare revision numbers here and set projectConfig only if the revision number has changed
74+
cm.configLock.Lock()
75+
cm.projectConfig = projectConfig
76+
cm.err = err
77+
cm.configLock.Unlock()
78+
}
79+
80+
func (cm *PollingProjectConfigManager) start(initialDatafile []byte, init bool) {
81+
8382
if init {
84-
update()
83+
cm.SyncConfig(initialDatafile)
8584
return
8685
}
86+
8787
t := time.NewTicker(cm.pollingInterval)
8888
for {
8989
select {
9090
case <-t.C:
91-
update()
91+
cm.SyncConfig([]byte{})
9292
case <-cm.exeCtx.GetContext().Done():
9393
cmLogger.Debug("Polling Config Manager Stopped")
9494
return
@@ -114,10 +114,10 @@ func NewPollingProjectConfigManagerWithOptions(exeCtx utils.ExecutionCtx, sdkKey
114114

115115
pollingProjectConfigManager := PollingProjectConfigManager{requester: requester, pollingInterval: pollingInterval, exeCtx: exeCtx}
116116

117-
pollingProjectConfigManager.activate(options.Datafile, true) // initial poll
117+
pollingProjectConfigManager.SyncConfig(options.Datafile) // initial poll
118118

119119
cmLogger.Debug("Polling Config Manager Initiated")
120-
go pollingProjectConfigManager.activate([]byte{}, false)
120+
go pollingProjectConfigManager.start([]byte{}, false)
121121
return &pollingProjectConfigManager
122122
}
123123

optimizely/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
package optimizely
1919

2020
// Version is the current version of the client
21-
const Version = "0.1.0-beta"
21+
const Version = "0.2.0"
2222

2323
// ClientName is the name of the client
2424
const ClientName = "go-sdk"

0 commit comments

Comments
 (0)