-
Notifications
You must be signed in to change notification settings - Fork 10
/
statsig_context.go
68 lines (59 loc) · 1.37 KB
/
statsig_context.go
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
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
}
type initContext struct {
Start time.Time
Success bool
Error error
Source EvaluationSource
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) copy() *initContext {
c.mu.RLock()
defer c.mu.RUnlock()
return &initContext{
Start: c.Start,
Success: c.Success,
Error: c.Error,
Source: c.Source,
}
}