@@ -8,18 +8,21 @@ import (
88)
99
1010const (
11- CommandEvaluateFlag = "evaluate"
12- CommandEvaluateAllFlags = "evaluateAll"
13- CommandIdentifyEvent = "identifyEvent"
14- CommandCustomEvent = "customEvent"
15- CommandAliasEvent = "aliasEvent"
16- CommandFlushEvents = "flushEvents"
17- CommandGetBigSegmentStoreStatus = "getBigSegmentStoreStatus"
18- CommandContextBuild = "contextBuild"
19- CommandContextConvert = "contextConvert"
20- CommandSecureModeHash = "secureModeHash"
21- CommandMigrationVariation = "migrationVariation"
22- CommandMigrationOperation = "migrationOperation"
11+ CommandEvaluateFlag = "evaluate"
12+ CommandEvaluateAllFlags = "evaluateAll"
13+ CommandIdentifyEvent = "identifyEvent"
14+ CommandCustomEvent = "customEvent"
15+ CommandAliasEvent = "aliasEvent"
16+ CommandFlushEvents = "flushEvents"
17+ CommandGetBigSegmentStoreStatus = "getBigSegmentStoreStatus"
18+ CommandContextBuild = "contextBuild"
19+ CommandContextConvert = "contextConvert"
20+ CommandSecureModeHash = "secureModeHash"
21+ CommandMigrationVariation = "migrationVariation"
22+ CommandMigrationOperation = "migrationOperation"
23+ CommandRegisterFlagChangeListener = "registerFlagChangeListener"
24+ CommandRegisterFlagValueChangeListener = "registerFlagValueChangeListener"
25+ CommandUnregisterListener = "unregisterListener"
2326)
2427
2528type ValueType string
@@ -33,16 +36,19 @@ const (
3336)
3437
3538type CommandParams struct {
36- Command string `json:"command"`
37- Evaluate * EvaluateFlagParams `json:"evaluate,omitempty"`
38- EvaluateAll * EvaluateAllFlagsParams `json:"evaluateAll,omitempty"`
39- CustomEvent * CustomEventParams `json:"customEvent,omitempty"`
40- IdentifyEvent * IdentifyEventParams `json:"identifyEvent,omitempty"`
41- ContextBuild * ContextBuildParams `json:"contextBuild,omitempty"`
42- ContextConvert * ContextConvertParams `json:"contextConvert,omitempty"`
43- SecureModeHash * SecureModeHashParams `json:"secureModeHash,omitempty"`
44- MigrationVariation * MigrationVariationParams `json:"migrationVariation,omitempty"`
45- MigrationOperation * MigrationOperationParams `json:"migrationOperation,omitempty"`
39+ Command string `json:"command"`
40+ Evaluate * EvaluateFlagParams `json:"evaluate,omitempty"`
41+ EvaluateAll * EvaluateAllFlagsParams `json:"evaluateAll,omitempty"`
42+ CustomEvent * CustomEventParams `json:"customEvent,omitempty"`
43+ IdentifyEvent * IdentifyEventParams `json:"identifyEvent,omitempty"`
44+ ContextBuild * ContextBuildParams `json:"contextBuild,omitempty"`
45+ ContextConvert * ContextConvertParams `json:"contextConvert,omitempty"`
46+ SecureModeHash * SecureModeHashParams `json:"secureModeHash,omitempty"`
47+ MigrationVariation * MigrationVariationParams `json:"migrationVariation,omitempty"`
48+ MigrationOperation * MigrationOperationParams `json:"migrationOperation,omitempty"`
49+ RegisterFlagChangeListener * RegisterFlagChangeListenerParams `json:"registerFlagChangeListener,omitempty"` //nolint:lll
50+ RegisterFlagValueChangeListener * RegisterFlagValueChangeListenerParams `json:"registerFlagValueChangeListener,omitempty"` //nolint:lll
51+ UnregisterListener * UnregisterListenerParams `json:"unregisterListener,omitempty"`
4652}
4753
4854type EvaluateFlagParams struct {
@@ -180,5 +186,39 @@ type HookExecutionEvaluationPayload struct {
180186
181187type HookExecutionTrackPayload struct {
182188 TrackSeriesContext TrackSeriesContext `json:"trackSeriesContext,omitempty"`
183- Stage HookStage `json:"stage,omitempty"`
189+ Stage HookStage `json:"stage,omitempty"`
190+ }
191+
192+ // RegisterFlagChangeListenerParams defines parameters for registering a general flag change listener.
193+ // The listener will be notified whenever any flag's configuration changes.
194+ type RegisterFlagChangeListenerParams struct {
195+ ListenerID string `json:"listenerId"`
196+ CallbackURI string `json:"callbackUri"`
197+ }
198+
199+ // RegisterFlagValueChangeListenerParams defines parameters for registering a flag value change listener.
200+ // The listener fires when the evaluated value of FlagKey changes for the given Context.
201+ type RegisterFlagValueChangeListenerParams struct {
202+ ListenerID string `json:"listenerId"`
203+ FlagKey string `json:"flagKey"`
204+ Context ldcontext.Context `json:"context"`
205+ DefaultValue ldvalue.Value `json:"defaultValue"`
206+ CallbackURI string `json:"callbackUri"`
207+ }
208+
209+ // UnregisterListenerParams defines parameters for unregistering a previously registered listener.
210+ // Works for both flag change and flag value change listeners.
211+ type UnregisterListenerParams struct {
212+ ListenerID string `json:"listenerId"`
213+ }
214+
215+ // ListenerNotification is the JSON payload POSTed by the test service to a callback URI when a
216+ // listener fires. OldValue and NewValue are only present for value-change notifications
217+ // (registerFlagValueChangeListener); they are nil for general flag-change notifications
218+ // (registerFlagChangeListener).
219+ type ListenerNotification struct {
220+ ListenerID string `json:"listenerId"`
221+ FlagKey string `json:"flagKey"`
222+ OldValue * ldvalue.Value `json:"oldValue,omitempty"`
223+ NewValue * ldvalue.Value `json:"newValue,omitempty"`
184224}
0 commit comments