Skip to content

Commit cc4cca0

Browse files
committed
default config cat client nil
1 parent a5b3cce commit cc4cca0

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

components/common-go/experiments/types.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,19 @@ func WithGitpodProxy(gitpodHost string) ClientOpt {
4949
}
5050
}
5151

52+
func WithDefaultClient(defaultClient Client) ClientOpt {
53+
return func(o *options) {
54+
o.defaultClient = defaultClient
55+
o.hasDefaultClient = true
56+
}
57+
}
58+
5259
type options struct {
53-
pollInterval time.Duration
54-
baseURL string
55-
sdkKey string
60+
pollInterval time.Duration
61+
baseURL string
62+
sdkKey string
63+
defaultClient Client
64+
hasDefaultClient bool
5665
}
5766

5867
// NewClient constructs a new experiments.Client. This is NOT A SINGLETON.
@@ -70,6 +79,9 @@ func NewClient(opts ...ClientOpt) Client {
7079
}
7180

7281
if opt.sdkKey == "" {
82+
if opt.hasDefaultClient {
83+
return opt.defaultClient
84+
}
7385
return NewAlwaysReturningDefaultValueClient()
7486
}
7587
logger := log.Log.Dup()

components/service-waiter/cmd/component.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ func init() {
148148
func startWaitFeatureFlag(ctx context.Context, timeout time.Duration) {
149149
featureFlagCtx, cancel := context.WithTimeout(ctx, timeout)
150150
defer cancel()
151-
client := experiments.NewClient()
152-
151+
client := experiments.NewClient(experiments.WithDefaultClient(nil))
153152
defaultSkip := true
154153
if client == nil {
155154
log.Error("failed to create experiments client, skip immediately")

0 commit comments

Comments
 (0)