...
1 package subsystems
2
3 import (
4 "net/http"
5
6 "github.com/launchdarkly/go-server-sdk/v6/interfaces"
7 )
8
9
10
11
12
13
14
15
16 type ClientContext interface {
17
18 GetSDKKey() string
19
20
21 GetApplicationInfo() interfaces.ApplicationInfo
22
23
24 GetHTTP() HTTPConfiguration
25
26
27 GetLogging() LoggingConfiguration
28
29
30 GetOffline() bool
31
32
33 GetServiceEndpoints() interfaces.ServiceEndpoints
34
35
36
37
38
39
40 GetDataSourceUpdateSink() DataSourceUpdateSink
41
42
43
44
45
46
47 GetDataStoreUpdateSink() DataStoreUpdateSink
48 }
49
50
51
52 type BasicClientContext struct {
53 SDKKey string
54 ApplicationInfo interfaces.ApplicationInfo
55 HTTP HTTPConfiguration
56 Logging LoggingConfiguration
57 Offline bool
58 ServiceEndpoints interfaces.ServiceEndpoints
59 DataSourceUpdateSink DataSourceUpdateSink
60 DataStoreUpdateSink DataStoreUpdateSink
61 }
62
63 func (b BasicClientContext) GetSDKKey() string { return b.SDKKey }
64
65 func (b BasicClientContext) GetApplicationInfo() interfaces.ApplicationInfo { return b.ApplicationInfo }
66
67 func (b BasicClientContext) GetHTTP() HTTPConfiguration {
68 ret := b.HTTP
69 if ret.CreateHTTPClient == nil {
70 ret.CreateHTTPClient = func() *http.Client {
71 client := *http.DefaultClient
72 return &client
73 }
74 }
75 return ret
76 }
77
78 func (b BasicClientContext) GetLogging() LoggingConfiguration { return b.Logging }
79
80 func (b BasicClientContext) GetOffline() bool { return b.Offline }
81
82 func (b BasicClientContext) GetServiceEndpoints() interfaces.ServiceEndpoints {
83 return b.ServiceEndpoints
84 }
85
86 func (b BasicClientContext) GetDataSourceUpdateSink() DataSourceUpdateSink {
87 return b.DataSourceUpdateSink
88 }
89
90 func (b BasicClientContext) GetDataStoreUpdateSink() DataStoreUpdateSink {
91 return b.DataStoreUpdateSink
92 }
93
View as plain text