4
4
package main
5
5
6
6
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"
12
7
"io/ioutil"
13
8
"log"
14
9
"os"
15
10
"path"
16
11
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
+
17
17
"github.com/pkg/profile"
18
18
)
19
19
@@ -23,55 +23,8 @@ func stressTest() {
23
23
For the test app, the biggest json file is used with 100 entities.
24
24
DATAFILES_DIR has to be set to point to the path where 100_entities.json is located.
25
25
*/
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
- }
31
26
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" )
75
28
76
29
datafile , err := ioutil .ReadFile (datafileDir )
77
30
if err != nil {
@@ -83,8 +36,10 @@ func stressTest() {
83
36
}
84
37
85
38
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
+ },
88
43
}
89
44
90
45
// Creates a default, canceleable context
@@ -99,7 +54,7 @@ func stressTest() {
99
54
log .Fatal (err )
100
55
}
101
56
102
- clientApp .IsFeatureEnabled (params . FeatureKey , user )
57
+ clientApp .IsFeatureEnabled ("feature_5" , user )
103
58
}
104
59
105
60
var RunMemProfile = "false"
0 commit comments