-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmodels.go
95 lines (76 loc) · 2.9 KB
/
models.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
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
package evaluation
type EvaluationRequest struct {
FlagKey string `json:"flag_key"`
EntityId string `json:"entity_id"`
Context map[string]string `json:"context"`
}
type clientTokenAuthentication struct {
Token string `json:"client_token"`
}
type jwtAuthentication struct {
Token string `json:"jwt_token"`
}
type FetchMode string
const (
FetchModeStreaming FetchMode = "streaming"
FetchModePolling FetchMode = "polling"
)
type ErrorStrategy string
const (
ErrorStrategyFail ErrorStrategy = "fail"
ErrorStrategyFallback ErrorStrategy = "fallback"
)
type clientOptions[T any] struct {
URL string `json:"url,omitempty"`
Authentication *T `json:"authentication,omitempty"`
UpdateInterval int `json:"update_interval,omitempty"`
Reference string `json:"reference,omitempty"`
FetchMode FetchMode `json:"fetch_mode,omitempty"`
ErrorStrategy ErrorStrategy `json:"error_strategy,omitempty"`
}
type Flag struct {
Key string `json:"key"`
Enabled bool `json:"enabled"`
Type string `json:"type"`
}
type VariantEvaluationResponse struct {
Match bool `json:"match"`
SegmentKeys []string `json:"segment_keys"`
Reason string `json:"reason"`
FlagKey string `json:"flag_key"`
VariantKey string `json:"variant_key"`
VariantAttachment string `json:"variant_attachment"`
RequestDurationMillis float64 `json:"request_duration_millis"`
Timestamp string `json:"timestamp"`
}
type BooleanEvaluationResponse struct {
Enabled bool `json:"enabled"`
FlagKey string `json:"flag_key"`
Reason string `json:"reason"`
RequestDurationMillis float64 `json:"request_duration_millis"`
Timestamp string `json:"timestamp"`
}
type ErrorEvaluationResponse struct {
FlagKey string `json:"flag_key"`
NamespaceKey string `json:"namespace_key"`
Reason string `json:"reason"`
}
type BatchEvaluationResponse struct {
Responses []*Response `json:"responses"`
RequestDurationMillis float64 `json:"request_duration_millis"`
}
type Response struct {
Type string `json:"type"`
VariantEvaluationResponse *VariantEvaluationResponse `json:"variant_evaluation_response,omitempty"`
BooleanEvaluationResponse *BooleanEvaluationResponse `json:"boolean_evaluation_response,omitempty"`
ErrorEvaluationResponse *ErrorEvaluationResponse `json:"error_evaluation_response,omitempty"`
}
type Result[R any] struct {
Status string `json:"status"`
Result *R `json:"result,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
}
type VariantResult Result[VariantEvaluationResponse]
type BooleanResult Result[BooleanEvaluationResponse]
type BatchResult Result[BatchEvaluationResponse]
type ListFlagsResult Result[[]Flag]