Skip to content

Commit 7b68d65

Browse files
remove unneeded stuff
1 parent ee18a11 commit 7b68d65

File tree

1 file changed

+11
-56
lines changed

1 file changed

+11
-56
lines changed

examples/main_profile_feature.go

Lines changed: 11 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
package main
55

66
import (
7-
"encoding/json"
8-
"github.com/optimizely/go-sdk/optimizely/client"
9-
"github.com/optimizely/go-sdk/optimizely/decision"
10-
"github.com/optimizely/go-sdk/optimizely/entities"
11-
"github.com/optimizely/go-sdk/optimizely/notification"
127
"io/ioutil"
138
"log"
149
"os"
1510
"path"
1611

12+
"github.com/optimizely/go-sdk/optimizely/client"
13+
"github.com/optimizely/go-sdk/optimizely/decision"
14+
"github.com/optimizely/go-sdk/optimizely/entities"
15+
"github.com/optimizely/go-sdk/optimizely/notification"
16+
1717
"github.com/pkg/profile"
1818
)
1919

@@ -23,55 +23,8 @@ func stressTest() {
2323
For the test app, the biggest json file is used with 100 entities.
2424
DATAFILES_DIR has to be set to point to the path where 100_entities.json is located.
2525
*/
26-
type isFeatureEnabledRequestParams struct {
27-
FeatureKey string `json:"feature_flag_key"`
28-
UserID string `json:"user_id"`
29-
Attributes map[string]interface{} `json:"attributes"`
30-
}
3126

32-
type Context struct {
33-
CustomEventDispatcher string `json:"custom_event_dispatcher"`
34-
RequestID string `json:"request_id"`
35-
UserProfileService string `json:"user_profile_service"`
36-
Datafile string `json:"datafile"`
37-
DispatchedEvents []map[string]interface{} `json:"dispatched_events"`
38-
}
39-
40-
strBytes := []byte(` { "context": {
41-
"datafile": "100_entities.json",
42-
"custom_event_dispatcher": "ProxyEventDispatcher",
43-
"request_id": "4e3e37e3-c7ae-4cb6-bbb5-f6ef93c84d43",
44-
"user_profile_service": "NoOpService",
45-
"user_profiles": [],
46-
"with_listener": []
47-
},
48-
"user_id": "test_user_1",
49-
"feature_flag_key": "feature_5",
50-
"attributes": {
51-
"attr_5": "testvalue"
52-
}
53-
}`)
54-
55-
var params isFeatureEnabledRequestParams
56-
err := json.Unmarshal(strBytes, &params)
57-
if err != nil {
58-
log.Fatal(err)
59-
}
60-
61-
var requestBodyMap map[string]*json.RawMessage
62-
63-
err = json.Unmarshal(strBytes, &requestBodyMap)
64-
if err != nil {
65-
log.Fatal(err)
66-
}
67-
68-
var fscCtx Context
69-
err = json.Unmarshal(*requestBodyMap["context"], &fscCtx)
70-
if err != nil {
71-
log.Fatal(err)
72-
}
73-
74-
var datafileDir = path.Join(os.Getenv("DATAFILES_DIR"), fscCtx.Datafile)
27+
var datafileDir = path.Join(os.Getenv("DATAFILES_DIR"), "100_entities.json")
7528

7629
datafile, err := ioutil.ReadFile(datafileDir)
7730
if err != nil {
@@ -83,8 +36,10 @@ func stressTest() {
8336
}
8437

8538
user := entities.UserContext{
86-
ID: params.UserID,
87-
Attributes: params.Attributes,
39+
ID: "test_user_1",
40+
Attributes: map[string]interface{}{
41+
"attr_5": "testvalue",
42+
},
8843
}
8944

9045
// Creates a default, canceleable context
@@ -99,7 +54,7 @@ func stressTest() {
9954
log.Fatal(err)
10055
}
10156

102-
clientApp.IsFeatureEnabled(params.FeatureKey, user)
57+
clientApp.IsFeatureEnabled("feature_5", user)
10358
}
10459

10560
var RunMemProfile = "false"

0 commit comments

Comments
 (0)