Skip to content

Commit fb212ce

Browse files
Merge pull request #102 from optimizely/pawel/fix_requester_despatcher
added requester to the dispatcher, and providing with highly customizable client
2 parents 2d89df4 + 78a8b02 commit fb212ce

File tree

11 files changed

+138
-177
lines changed

11 files changed

+138
-177
lines changed

examples/main.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ package main
55

66
import (
77
"fmt"
8+
"time"
9+
810
"github.com/optimizely/go-sdk/optimizely/client"
911
"github.com/optimizely/go-sdk/optimizely/entities"
12+
"github.com/optimizely/go-sdk/optimizely/event"
1013
"github.com/optimizely/go-sdk/optimizely/logging"
14+
"github.com/optimizely/go-sdk/optimizely/notification"
1115
)
1216

1317
func main() {
@@ -55,4 +59,15 @@ func main() {
5559
enabled, _ = app.IsFeatureEnabled("mutext_feat", user)
5660
fmt.Printf("Is feature enabled? %v\n", enabled)
5761
app.Close() // user can close dispatcher
62+
63+
/************* Setting Polling Interval ********************/
64+
65+
notificationCenter := notification.NewNotificationCenter()
66+
67+
app = optimizelyFactory.GetClient(
68+
client.PollingConfigManager("4SLpaJA1r1pgE6T2CoMs9q", time.Second, nil),
69+
client.CompositeDecisionService(notificationCenter),
70+
client.BatchEventProcessor(event.DefaultBatchSize, event.DefaultEventQueueSize, event.DefaultEventFlushInterval),
71+
)
72+
app.Close()
5873
}

optimizely/client/client.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ type OptimizelyClient struct {
3838
configManager optimizely.ProjectConfigManager
3939
decisionService decision.Service
4040
eventProcessor event.Processor
41-
isValid bool
4241

4342
executionCtx utils.ExecutionCtx
4443
}
@@ -279,9 +278,6 @@ func (o *OptimizelyClient) getFeatureDecision(featureKey string, userContext ent
279278

280279
// GetProjectConfig returns the current ProjectConfig or nil if the instance is not valid
281280
func (o *OptimizelyClient) GetProjectConfig() (projectConfig optimizely.ProjectConfig, err error) {
282-
if !o.isValid {
283-
return nil, fmt.Errorf("optimizely instance is not valid")
284-
}
285281

286282
projectConfig, err = o.configManager.GetConfig()
287283
if err != nil {

0 commit comments

Comments
 (0)