Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Expose raw config bytes and etag #224

Merged
merged 2 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ type Client struct {
eventQueue *EventManager
localBucketing LocalBucketing
platformData *PlatformData

// Set to true when the client has been initialized, regardless of whether the config has loaded successfully.
isInitialized bool
internalOnInitializedChannel chan bool
Expand Down Expand Up @@ -171,6 +170,16 @@ func (c *Client) generateBucketedConfig(user User) (config *BucketedUserConfig,
return
}

func (c *Client) GetRawConfig() (config []byte, etag string, err error) {
if c.configManager == nil {
return nil, "", errors.New("cannot read raw config; config manager is nil")
}
if c.configManager.HasConfig() {
return c.configManager.rawConfig, c.configManager.configETag, nil
}
return nil, "", errors.New("cannot read raw config; config manager has no config")
}

func createNullableString(val string) *proto.NullableString {
if val == "" {
return &proto.NullableString{Value: "", IsNull: true}
Expand Down
4 changes: 3 additions & 1 deletion configmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type ConfigReceiver interface {

type EnvironmentConfigManager struct {
sdkKey string
rawConfig []byte
configETag string
localBucketing ConfigReceiver
firstLoad bool
Expand Down Expand Up @@ -166,8 +167,9 @@ func (e *EnvironmentConfigManager) setConfig(config []byte, eTag string) error {
if err != nil {
return err
}

e.rawConfig = config
e.hasConfig.Store(true)

return nil
}

Expand Down