-
Notifications
You must be signed in to change notification settings - Fork 10
/
evaluation_details.go
64 lines (55 loc) · 1.53 KB
/
evaluation_details.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
package statsig
import "fmt"
type EvaluationSource string
const (
SourceUninitialized EvaluationSource = "Uninitialized"
SourceNetwork EvaluationSource = "Network"
SourceNetworkNotModified EvaluationSource = "NetworkNotModified"
SourceBootstrap EvaluationSource = "Bootstrap"
SourceDataAdapter EvaluationSource = "DataAdapter"
)
type EvaluationReason string
const (
ReasonNone EvaluationReason = "None"
ReasonLocalOverride EvaluationReason = "LocalOverride"
ReasonUnrecognized EvaluationReason = "Unrecognized"
ReasonPersisted EvaluationReason = "Persisted"
)
type EvaluationDetails struct {
Source EvaluationSource
Reason EvaluationReason
ConfigSyncTime int64
InitTime int64
ServerTime int64
}
func (d EvaluationDetails) detailedReason() string {
if d.Reason == ReasonNone {
return string(d.Source)
} else {
return fmt.Sprintf("%s:%s", d.Source, d.Reason)
}
}
func newEvaluationDetails(
source EvaluationSource,
reason EvaluationReason,
configSyncTime int64,
initTime int64,
) *EvaluationDetails {
return &EvaluationDetails{
Source: source,
Reason: reason,
ConfigSyncTime: configSyncTime,
InitTime: initTime,
ServerTime: getUnixMilli(),
}
}
func reconstructEvaluationDetailsFromPersisted(
configSyncTime int64,
) *EvaluationDetails {
return &EvaluationDetails{
Reason: ReasonPersisted,
ConfigSyncTime: configSyncTime,
InitTime: 0, // unsupported for persisted
ServerTime: getUnixMilli(),
}
}