Skip to content

Commit

Permalink
Change option name to EnableBetaRealtimeUpdates
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieSinn committed May 9, 2024
1 parent 07549fe commit aede7b5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 43 deletions.
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func NewClient(sdkKey string, options *Options) (*Client, error) {
}

// If SSE is enabled - the first config pull will trigger SSE to be started.
if !c.DevCycleOptions.EnableRealtimeUpdates {
if !c.DevCycleOptions.EnableBetaRealtimeUpdates {
err = c.configManager.StartPolling(options.ConfigPollingIntervalMS)
}
return c, err
Expand Down
6 changes: 3 additions & 3 deletions configmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func NewEnvironmentConfigManager(

configManager.context, configManager.shutdown = context.WithCancel(context.Background())

if options.EnableRealtimeUpdates {
if options.EnableBetaRealtimeUpdates {
configManager.sseManager = newSSEManager(configManager, options, cfg)
go configManager.ssePollingManager()
}
Expand Down Expand Up @@ -131,7 +131,7 @@ func (e *EnvironmentConfigManager) ssePollingManager() {
case api.ClientEventType_ConfigUpdated:
eventData := event.EventData.(map[string]string)

if url, ok := eventData["sseUrl"]; ok && e.options.EnableRealtimeUpdates {
if url, ok := eventData["sseUrl"]; ok && e.options.EnableBetaRealtimeUpdates {
// Reconnect SSE
e.sseManager.StopSSE()
err := e.StartSSE(url)
Expand All @@ -150,7 +150,7 @@ func (e *EnvironmentConfigManager) ssePollingManager() {
}

func (e *EnvironmentConfigManager) StartSSE(url string) error {
if !e.options.EnableRealtimeUpdates {
if !e.options.EnableBetaRealtimeUpdates {
return fmt.Errorf("realtime updates are disabled. Cannot start SSE")
}
return e.sseManager.StartSSEOverride(url)
Expand Down
34 changes: 1 addition & 33 deletions configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,6 @@ import (

type EventQueueOptions = api.EventQueueOptions

type contextKey string

func (c contextKey) String() string {
return "auth " + string(c)
}

var (
// ContextOAuth2 takes a oauth2.TokenSource as authentication for the request.
ContextOAuth2 = contextKey("token")

// ContextBasicAuth takes BasicAuth as authentication for the request.
ContextBasicAuth = contextKey("basic")

// ContextAccessToken takes a string oauth2 access token as authentication for the request.
ContextAccessToken = contextKey("accesstoken")

// ContextAPIKey takes an APIKey as authentication for the request
ContextAPIKey = contextKey("apikey")
)

// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
type BasicAuth struct {
UserName string `json:"userName,omitempty"`
Password string `json:"password,omitempty"`
}

// APIKey provides API key based authentication to a request passed via context using ContextAPIKey
type APIKey struct {
Key string
Prefix string
}

type AdvancedOptions struct {
OverridePlatformData *api.PlatformData
RealtimeUpdatesTimeout time.Duration
Expand All @@ -61,7 +29,7 @@ type Options struct {
RequestTimeout time.Duration `json:"requestTimeout,omitempty"`
DisableAutomaticEventLogging bool `json:"disableAutomaticEventLogging,omitempty"`
DisableCustomEventLogging bool `json:"disableCustomEventLogging,omitempty"`
EnableRealtimeUpdates bool `json:"enableRealtimeUpdates,omitempty"`
EnableBetaRealtimeUpdates bool `json:"enableRealtimeUpdates,omitempty"`
MaxEventQueueSize int `json:"maxEventsPerFlush,omitempty"`
FlushEventQueueSize int `json:"minEventsPerFlush,omitempty"`
ConfigCDNURI string
Expand Down
6 changes: 3 additions & 3 deletions openfeature_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ func createUserFromEvaluationContext(evalCtx openfeature.FlattenedContext) (User
if targetingKey, ok := evalCtx[openfeature.TargetingKey].(string); ok {
userId = targetingKey
} else {
return DVCUser{}, errors.New("targetingKey must be a string")
return User{}, errors.New("targetingKey must be a string")
}
}
if userId == "" {
Expand All @@ -329,13 +329,13 @@ func createUserFromEvaluationContext(evalCtx openfeature.FlattenedContext) (User
if userIdValue, ok := evalCtx[DEVCYCLE_USER_ID_KEY].(string); ok {
userId = userIdValue
} else {
return DVCUser{}, errors.New("userId must be a string")
return User{}, errors.New("userId must be a string")
}
}
}

if userId == "" {
return DVCUser{}, errors.New("targetingKey or userId must be provided")
return User{}, errors.New("targetingKey or userId must be provided")
}
user := User{
UserId: userId,
Expand Down
6 changes: 3 additions & 3 deletions testing_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ var (
}
test_options_sse = &Options{
// use defaults that will be set by the CheckDefaults
EventFlushIntervalMS: time.Second * 30,
ConfigPollingIntervalMS: time.Second * 10,
EnableRealtimeUpdates: true,
EventFlushIntervalMS: time.Second * 30,
ConfigPollingIntervalMS: time.Second * 10,
EnableBetaRealtimeUpdates: true,
}
)

Expand Down

0 comments on commit aede7b5

Please sign in to comment.