-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathstatsig_context.go
More file actions
108 lines (95 loc) · 2.52 KB
/
statsig_context.go
File metadata and controls
108 lines (95 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package statsig
import (
"sync"
"time"
)
type errorContext struct {
evalContext *evalContext
Caller string `json:"tag,omitempty"`
BypassDedupe bool
LogToOutput bool
EventCount int
}
type evalContext struct {
Caller string `json:"tag,omitempty"`
ConfigName string `json:"configName,omitempty"`
ClientKey string `json:"clientKey,omitempty"`
Hash string `json:"hash,omitempty"`
TargetAppID string
IncludeLocalOverrides bool
IsManualExposure bool
IsExperiment bool
DisableLogExposures bool
PersistedValues UserPersistedValues
IncludeConfigType bool
ConfigTypesToInclude []ConfigType
EvalSamplingRate *int
EvalHasSeenAnalyticalGates bool
UseControlForUsersNotInExperiment bool
Statsig *Client
}
type initContext struct {
Start time.Time
Success bool
Error error
Source EvaluationSource
CurrentSourceAPI string
SourceAPI string
StorePopulated bool
mu sync.RWMutex
}
func newInitContext() *initContext {
return &initContext{Start: time.Now(), Success: false, Source: SourceUninitialized}
}
func (c *initContext) setSuccess(success bool) {
c.mu.Lock()
defer c.mu.Unlock()
c.Success = success
}
func (c *initContext) setError(err error) {
c.mu.Lock()
defer c.mu.Unlock()
c.Error = err
}
func (c *initContext) setSource(source EvaluationSource) {
c.mu.Lock()
defer c.mu.Unlock()
c.Source = source
}
func (c *initContext) setSourceAPI(sourceAPI string) {
c.mu.Lock()
defer c.mu.Unlock()
c.SourceAPI = sourceAPI
}
func (c *initContext) setCurrentSourceAPI(currentSourceAPI string) {
c.mu.Lock()
defer c.mu.Unlock()
c.CurrentSourceAPI = currentSourceAPI
}
func (c *initContext) setStorePopulated(populated bool) {
c.mu.Lock()
defer c.mu.Unlock()
c.StorePopulated = populated
}
func (c *initContext) copy() *initContext {
c.mu.RLock()
defer c.mu.RUnlock()
return &initContext{
Start: c.Start,
Success: c.Success,
Error: c.Error,
Source: c.Source,
}
}
func (c *initContext) toInitDetails() InitializeDetails {
c.mu.RLock()
defer c.mu.RUnlock()
return InitializeDetails{
Duration: time.Since(c.Start),
Success: c.Success,
Error: c.Error,
Source: c.Source,
SourceAPI: c.SourceAPI,
StorePopulated: c.StorePopulated,
}
}