From f5753b1bc7a0f3549045a33b946eb8dadddc8f9f Mon Sep 17 00:00:00 2001 From: vahid torkaman Date: Wed, 22 May 2024 12:09:14 +0200 Subject: [PATCH] move context calculations out of a go routine --- confidence/confidence.go | 13 ++++++------- demo/GoDemoApp.go | 3 +-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/confidence/confidence.go b/confidence/confidence.go index 35668ac..22df873 100644 --- a/confidence/confidence.go +++ b/confidence/confidence.go @@ -79,16 +79,15 @@ func (e Confidence) PutContext(key string, value interface{}) { } func (e Confidence) Track(ctx context.Context, eventName string, message map[string]interface{}) { + newMap := e.GetContext() + + for key, value := range message { + newMap[key] = value + } + go func() { currentTime := time.Now() iso8601Time := currentTime.Format(time.RFC3339) - - newMap := e.GetContext() - - for key, value := range message { - newMap[key] = value - } - event := Event { EventDefinition: fmt.Sprintf("eventDefinitions/%s", eventName), EventTime: iso8601Time, diff --git a/demo/GoDemoApp.go b/demo/GoDemoApp.go index d776304..3556b2f 100644 --- a/demo/GoDemoApp.go +++ b/demo/GoDemoApp.go @@ -3,7 +3,6 @@ package main import ( "context" "fmt" - "time" "github.com/google/uuid" "github.com/open-feature/go-sdk/openfeature" @@ -12,7 +11,7 @@ import ( ) func main() { - clientSecret := "xa0fQ4WKSvuxdjPtesupleiSbZeik6Gf" + clientSecret := "CLIENT_SECRET" fmt.Println("Fetching the flags...") confidence := c.NewConfidenceBuilder().SetAPIConfig(c.APIConfig{APIKey: clientSecret}).Build()