@@ -12,15 +12,23 @@ import (
12
12
"github.com/launchdarkly/go-sdk-common/v3/ldreason"
13
13
"github.com/launchdarkly/go-sdk-common/v3/ldvalue"
14
14
"github.com/open-feature/go-sdk/openfeature"
15
-
16
- ld "github.com/launchdarkly/go-server-sdk/v7"
17
15
)
18
16
19
17
var errKeyMissing = errors .New ("key and targetingKey attributes are missing, at least 1 required" )
20
18
21
19
// Scream at compile time if Provider does not implement FeatureProvider
22
20
var _ openfeature.FeatureProvider = (* Provider )(nil )
23
21
22
+ // LDClient is the narrowed local interface for the parts of the
23
+ // `*ld.LDClient` LaunchDarkly client used by the provider.
24
+ type LDClient interface {
25
+ BoolVariationDetail (key string , context ldcontext.Context , defaultVal bool ) (bool , ldreason.EvaluationDetail , error )
26
+ IntVariationDetail (key string , context ldcontext.Context , defaultVal int ) (int , ldreason.EvaluationDetail , error )
27
+ Float64VariationDetail (key string , context ldcontext.Context , defaultVal float64 ) (float64 , ldreason.EvaluationDetail , error )
28
+ StringVariationDetail (key string , context ldcontext.Context , defaultVal string ) (string , ldreason.EvaluationDetail , error )
29
+ JSONVariationDetail (key string , context ldcontext.Context , defaultVal ldvalue.Value ) (ldvalue.Value , ldreason.EvaluationDetail , error )
30
+ }
31
+
24
32
type Option func (* options )
25
33
26
34
// options contains all the optional arguments supported by Provider.
@@ -47,11 +55,11 @@ func WithKindAttr(name string) Option {
47
55
// Provider implements the FeatureProvider interface for LaunchDarkly.
48
56
type Provider struct {
49
57
options
50
- client * ld. LDClient
58
+ client LDClient
51
59
}
52
60
53
61
// NewProvider creates a new LaunchDarkly OpenFeature Provider instance.
54
- func NewProvider (ldclient * ld. LDClient , opts ... Option ) * Provider {
62
+ func NewProvider (ldclient LDClient , opts ... Option ) * Provider {
55
63
p := & Provider {
56
64
client : ldclient ,
57
65
options : options {
0 commit comments