-
Notifications
You must be signed in to change notification settings - Fork 34
/
hooks.go
60 lines (53 loc) · 1.9 KB
/
hooks.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
package openfeature
import (
"github.com/open-feature/go-sdk/openfeature"
)
// Hook allows application developers to add arbitrary behavior to the flag evaluation lifecycle.
// They operate similarly to middleware in many web frameworks.
// https://github.com/open-feature/spec/blob/main/specification/hooks.md
//
// Deprecated: use github.com/open-feature/go-sdk/openfeature.Hook, instead.
type Hook = openfeature.Hook
// HookHints contains a map of hints for hooks
//
// Deprecated: use github.com/open-feature/go-sdk/openfeature.HookHints,
// instead.
type HookHints = openfeature.HookHints
// NewHookHints constructs HookHints
//
// Deprecated: use github.com/open-feature/go-sdk/openfeature.NewHookHints,
// instead.
func NewHookHints(mapOfHints map[string]interface{}) HookHints {
return openfeature.NewHookHints(mapOfHints)
}
// HookContext defines the base level fields of a hook context
//
// Deprecated: use github.com/open-feature/go-sdk/openfeature.HookContext,
// instead.
type HookContext = openfeature.HookContext
// NewHookContext constructs HookContext
// Allows for simplified hook test cases while maintaining immutability
//
// Deprecated: use github.com/open-feature/go-sdk/openfeature.NewHookContext,
// instead.
func NewHookContext(
flagKey string,
flagType Type,
defaultValue interface{},
clientMetadata ClientMetadata,
providerMetadata Metadata,
evaluationContext EvaluationContext,
) HookContext {
return openfeature.NewHookContext(flagKey, flagType, defaultValue, clientMetadata, providerMetadata, evaluationContext)
}
// UnimplementedHook implements all hook methods with empty functions
// Include UnimplementedHook in your hook struct to avoid defining empty functions
// e.g.
//
// type MyHook = openfeature.MyHook
// UnimplementedHook
// }
//
// Deprecated: use
// github.com/open-feature/go-sdk/openfeature.UnimplementedHook, instead.
type UnimplementedHook = openfeature.UnimplementedHook