forked from Unleash/unleash-client-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UnleashConfig.java
722 lines (606 loc) · 25.7 KB
/
UnleashConfig.java
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
package io.getunleash.util;
import static io.getunleash.DefaultUnleash.UNKNOWN_STRATEGY;
import io.getunleash.CustomHttpHeadersProvider;
import io.getunleash.DefaultCustomHttpHeadersProviderImpl;
import io.getunleash.UnleashContextProvider;
import io.getunleash.UnleashException;
import io.getunleash.event.NoOpSubscriber;
import io.getunleash.event.UnleashSubscriber;
import io.getunleash.lang.Nullable;
import io.getunleash.metric.DefaultHttpMetricsSender;
import io.getunleash.repository.HttpFeatureFetcher;
import io.getunleash.repository.ToggleBootstrapProvider;
import io.getunleash.strategy.Strategy;
import java.io.File;
import java.math.BigInteger;
import java.net.*;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer;
public class UnleashConfig {
public static final String UNLEASH_APP_NAME_HEADER = "UNLEASH-APPNAME";
public static final String UNLEASH_INSTANCE_ID_HEADER = "UNLEASH-INSTANCEID";
private final URI unleashAPI;
private final UnleashURLs unleashURLs;
private final Map<String, String> customHttpHeaders;
private final CustomHttpHeadersProvider customHttpHeadersProvider;
private final String appName;
private final String environment;
private final String instanceId;
private final String sdkVersion;
private final String backupFile;
private final String clientSpecificationVersion;
@Nullable private final String projectName;
@Nullable private final String namePrefix;
private final long fetchTogglesInterval;
private final Duration fetchTogglesConnectTimeout;
private final Duration fetchTogglesReadTimeout;
private final boolean disablePolling;
private final long sendMetricsInterval;
private final Duration sendMetricsConnectTimeout;
private final Duration sendMetricsReadTimeout;
private final boolean disableMetrics;
private final boolean isProxyAuthenticationByJvmProperties;
private final UnleashFeatureFetcherFactory unleashFeatureFetcherFactory;
private final MetricSenderFactory metricSenderFactory;
private final UnleashContextProvider contextProvider;
private final boolean synchronousFetchOnInitialisation;
private final UnleashScheduledExecutor unleashScheduledExecutor;
private final UnleashSubscriber unleashSubscriber;
@Nullable private final Strategy fallbackStrategy;
@Nullable private final ToggleBootstrapProvider toggleBootstrapProvider;
@Nullable private final Proxy proxy;
@Nullable private final Consumer<UnleashException> startupExceptionHandler;
private UnleashConfig(
@Nullable URI unleashAPI,
Map<String, String> customHttpHeaders,
CustomHttpHeadersProvider customHttpHeadersProvider,
@Nullable String appName,
String environment,
@Nullable String instanceId,
String sdkVersion,
String backupFile,
@Nullable String projectName,
@Nullable String namePrefix,
long fetchTogglesInterval,
Duration fetchTogglesConnectTimeout,
Duration fetchTogglesReadTimeout,
boolean disablePolling,
long sendMetricsInterval,
Duration sendMetricsConnectTimeout,
Duration sendMetricsReadTimeout,
boolean disableMetrics,
UnleashContextProvider contextProvider,
boolean isProxyAuthenticationByJvmProperties,
boolean synchronousFetchOnInitialisation,
UnleashFeatureFetcherFactory unleashFeatureFetcherFactory,
MetricSenderFactory metricSenderFactory,
@Nullable UnleashScheduledExecutor unleashScheduledExecutor,
@Nullable UnleashSubscriber unleashSubscriber,
@Nullable Strategy fallbackStrategy,
@Nullable ToggleBootstrapProvider unleashBootstrapProvider,
@Nullable Proxy proxy,
@Nullable Authenticator proxyAuthenticator,
@Nullable Consumer<UnleashException> startupExceptionHandler) {
if (appName == null) {
throw new IllegalStateException("You are required to specify the unleash appName");
}
if (instanceId == null) {
throw new IllegalStateException("You are required to specify the unleash instanceId");
}
if (unleashAPI == null) {
throw new IllegalStateException("You are required to specify the unleashAPI url");
}
if (unleashScheduledExecutor == null) {
throw new IllegalStateException("You are required to specify a scheduler");
}
if (unleashSubscriber == null) {
throw new IllegalStateException("You are required to specify a subscriber");
}
if (fallbackStrategy == null) {
this.fallbackStrategy = UNKNOWN_STRATEGY;
} else {
this.fallbackStrategy = fallbackStrategy;
}
if (isProxyAuthenticationByJvmProperties && proxyAuthenticator == null) {
enableProxyAuthentication();
} else if (proxyAuthenticator != null) {
Authenticator.setDefault(proxyAuthenticator);
}
this.unleashAPI = unleashAPI;
this.customHttpHeaders = customHttpHeaders;
this.customHttpHeadersProvider = customHttpHeadersProvider;
this.unleashURLs = new UnleashURLs(unleashAPI);
this.appName = appName;
this.environment = environment;
this.instanceId = instanceId;
this.sdkVersion = sdkVersion;
this.backupFile = backupFile;
this.projectName = projectName;
this.namePrefix = namePrefix;
this.fetchTogglesInterval = fetchTogglesInterval;
this.fetchTogglesConnectTimeout = fetchTogglesConnectTimeout;
this.fetchTogglesReadTimeout = fetchTogglesReadTimeout;
this.disablePolling = disablePolling;
this.sendMetricsInterval = sendMetricsInterval;
this.sendMetricsConnectTimeout = sendMetricsConnectTimeout;
this.sendMetricsReadTimeout = sendMetricsReadTimeout;
this.disableMetrics = disableMetrics;
this.contextProvider = contextProvider;
this.isProxyAuthenticationByJvmProperties = isProxyAuthenticationByJvmProperties;
this.synchronousFetchOnInitialisation = synchronousFetchOnInitialisation;
this.unleashScheduledExecutor = unleashScheduledExecutor;
this.unleashSubscriber = unleashSubscriber;
this.toggleBootstrapProvider = unleashBootstrapProvider;
this.proxy = proxy;
this.unleashFeatureFetcherFactory = unleashFeatureFetcherFactory;
this.metricSenderFactory = metricSenderFactory;
this.clientSpecificationVersion =
UnleashProperties.getProperty("client.specification.version");
this.startupExceptionHandler = startupExceptionHandler;
}
public static Builder builder() {
return new Builder();
}
public static void setRequestProperties(HttpURLConnection connection, UnleashConfig config) {
connection.setRequestProperty(UNLEASH_APP_NAME_HEADER, config.getAppName());
connection.setRequestProperty(UNLEASH_INSTANCE_ID_HEADER, config.getInstanceId());
connection.setRequestProperty("User-Agent", config.getAppName());
connection.setRequestProperty(
"Unleash-Client-Spec", config.getClientSpecificationVersion());
config.getCustomHttpHeaders().forEach(connection::setRequestProperty);
config.customHttpHeadersProvider.getCustomHeaders().forEach(connection::setRequestProperty);
}
private void enableProxyAuthentication() {
// http.proxyUser http.proxyPassword is only consumed by Apache HTTP Client, for
// HttpUrlConnection we have to define an Authenticator
Authenticator.setDefault(new SystemProxyAuthenticator());
}
public URI getUnleashAPI() {
return unleashAPI;
}
public Map<String, String> getCustomHttpHeaders() {
return customHttpHeaders;
}
public CustomHttpHeadersProvider getCustomHttpHeadersProvider() {
return customHttpHeadersProvider;
}
public String getAppName() {
return appName;
}
public String getEnvironment() {
return environment;
}
public String getInstanceId() {
return instanceId;
}
public String getSdkVersion() {
return sdkVersion;
}
public String getClientSpecificationVersion() {
return clientSpecificationVersion;
}
public @Nullable String getProjectName() {
return projectName;
}
public long getFetchTogglesInterval() {
return fetchTogglesInterval;
}
public Duration getFetchTogglesConnectTimeout() {
return fetchTogglesConnectTimeout;
}
public Duration getFetchTogglesReadTimeout() {
return fetchTogglesReadTimeout;
}
public boolean isDisablePolling() {
return disablePolling;
}
public long getSendMetricsInterval() {
return sendMetricsInterval;
}
public Duration getSendMetricsConnectTimeout() {
return sendMetricsConnectTimeout;
}
public Duration getSendMetricsReadTimeout() {
return sendMetricsReadTimeout;
}
public UnleashURLs getUnleashURLs() {
return unleashURLs;
}
public boolean isDisableMetrics() {
return disableMetrics;
}
public String getBackupFile() {
return this.backupFile;
}
@Nullable
public String getApiKey() {
String auth = this.customHttpHeadersProvider.getCustomHeaders().get("Authorization");
if (auth == null) {
auth = this.customHttpHeaders.get("Authorization");
}
return auth;
}
public String getClientIdentifier() {
try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
if (getApiKey() != null) {
md.update(getApiKey().getBytes(StandardCharsets.UTF_8));
}
md.update(getAppName().getBytes(StandardCharsets.UTF_8));
md.update(getInstanceId().getBytes(StandardCharsets.UTF_8));
return new BigInteger(1, md.digest()).toString(16);
} catch (NoSuchAlgorithmException nse) {
throw new IllegalStateException("Could not build hash for client", nse);
}
}
public boolean isSynchronousFetchOnInitialisation() {
return synchronousFetchOnInitialisation;
}
public UnleashContextProvider getContextProvider() {
return contextProvider;
}
public UnleashScheduledExecutor getScheduledExecutor() {
return unleashScheduledExecutor;
}
public UnleashSubscriber getSubscriber() {
return unleashSubscriber;
}
public boolean isProxyAuthenticationByJvmProperties() {
return isProxyAuthenticationByJvmProperties;
}
@Nullable
public Strategy getFallbackStrategy() {
return fallbackStrategy;
}
@Nullable
public ToggleBootstrapProvider getToggleBootstrapProvider() {
return toggleBootstrapProvider;
}
@Nullable
public String getNamePrefix() {
return namePrefix;
}
@Nullable
public Proxy getProxy() {
return proxy;
}
public MetricSenderFactory getMetricSenderFactory() {
return this.metricSenderFactory;
}
public UnleashFeatureFetcherFactory getUnleashFeatureFetcherFactory() {
return this.unleashFeatureFetcherFactory;
}
@Nullable
public Consumer<UnleashException> getStartupExceptionHandler() {
return startupExceptionHandler;
}
static class SystemProxyAuthenticator extends Authenticator {
@Override
protected @Nullable PasswordAuthentication getPasswordAuthentication() {
if (getRequestorType() == RequestorType.PROXY) {
final String proto = getRequestingProtocol().toLowerCase();
final String proxyHost = System.getProperty(proto + ".proxyHost", "");
final String proxyPort = System.getProperty(proto + ".proxyPort", "");
final String proxyUser = System.getProperty(proto + ".proxyUser", "");
final String proxyPassword = System.getProperty(proto + ".proxyPassword", "");
// Only apply PasswordAuthentication to requests to the proxy itself - if not set
// just ignore
if (getRequestingHost().equalsIgnoreCase(proxyHost)
&& Integer.parseInt(proxyPort) == getRequestingPort()) {
return new PasswordAuthentication(proxyUser, proxyPassword.toCharArray());
}
}
return null;
}
}
static class CustomProxyAuthenticator extends Authenticator {
private final Proxy proxy;
private final String proxyUser;
private final String proxyPassword;
public CustomProxyAuthenticator(Proxy proxy, String proxyUser, String proxyPassword) {
this.proxy = proxy;
this.proxyUser = proxyUser;
this.proxyPassword = proxyPassword;
}
@Override
protected @Nullable PasswordAuthentication getPasswordAuthentication() {
if (getRequestorType() == RequestorType.PROXY
&& proxy.type() == Proxy.Type.HTTP
&& proxy.address() instanceof InetSocketAddress) {
final String proxyHost = ((InetSocketAddress) proxy.address()).getHostName();
final int proxyPort = ((InetSocketAddress) proxy.address()).getPort();
// Only apply PasswordAuthentication to requests to the proxy
// itself - if not set
// just ignore
if (getRequestingHost().equalsIgnoreCase(proxyHost)
&& proxyPort == getRequestingPort()) {
return new PasswordAuthentication(proxyUser, proxyPassword.toCharArray());
}
}
return null;
}
}
public static class Builder {
private @Nullable URI unleashAPI;
private Map<String, String> customHttpHeaders = new HashMap<>();
private CustomHttpHeadersProvider customHttpHeadersProvider =
new DefaultCustomHttpHeadersProviderImpl();
private @Nullable String appName;
private String environment = "default";
private String instanceId = getDefaultInstanceId();
private final String sdkVersion = getDefaultSdkVersion();
private @Nullable String backupFile;
private @Nullable String projectName;
private @Nullable String namePrefix;
private long fetchTogglesInterval = 10;
private Duration fetchTogglesConnectTimeout = Duration.ofSeconds(10);
private Duration fetchTogglesReadTimeout = Duration.ofSeconds(10);
private boolean disablePolling = false;
private long sendMetricsInterval = 60;
private Duration sendMetricsConnectTimeout = Duration.ofSeconds(10);
private Duration sendMetricsReadTimeout = Duration.ofSeconds(10);
private boolean disableMetrics = false;
private UnleashFeatureFetcherFactory unleashFeatureFetcherFactory = HttpFeatureFetcher::new;
private MetricSenderFactory unleashMetricSenderFactory = DefaultHttpMetricsSender::new;
private UnleashContextProvider contextProvider =
UnleashContextProvider.getDefaultProvider();
private boolean synchronousFetchOnInitialisation = false;
private @Nullable UnleashScheduledExecutor scheduledExecutor;
private @Nullable UnleashSubscriber unleashSubscriber;
private boolean isProxyAuthenticationByJvmProperties;
private @Nullable Strategy fallbackStrategy;
private @Nullable ToggleBootstrapProvider toggleBootstrapProvider;
private @Nullable Proxy proxy;
private @Nullable Authenticator proxyAuthenticator;
private @Nullable Consumer<UnleashException> startupExceptionHandler;
private static String getHostname() {
String hostName = System.getProperty("hostname");
if (hostName == null || hostName.isEmpty()) {
try {
hostName = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
}
}
return hostName + "-";
}
static String getDefaultInstanceId() {
return getHostname() + "generated-" + Math.round(Math.random() * 1000000.0D);
}
public Builder unleashAPI(URI unleashAPI) {
this.unleashAPI = unleashAPI;
return this;
}
public Builder unleashAPI(String unleashAPI) {
this.unleashAPI = URI.create(unleashAPI);
return this;
}
public Builder customHttpHeader(String name, String value) {
this.customHttpHeaders.put(name, value);
return this;
}
public Builder customHttpHeadersProvider(CustomHttpHeadersProvider provider) {
this.customHttpHeadersProvider = provider;
return this;
}
public Builder appName(String appName) {
this.appName = appName;
return this;
}
public Builder environment(String environment) {
this.environment = environment;
return this;
}
public Builder instanceId(String instanceId) {
this.instanceId = instanceId;
return this;
}
public Builder projectName(String projectName) {
this.projectName = projectName;
return this;
}
public Builder namePrefix(String namePrefix) {
this.namePrefix = namePrefix;
return this;
}
public Builder unleashFeatureFetcherFactory(
UnleashFeatureFetcherFactory unleashFeatureFetcherFactory) {
this.unleashFeatureFetcherFactory = unleashFeatureFetcherFactory;
return this;
}
public Builder metricsSenderFactory(MetricSenderFactory metricSenderFactory) {
this.unleashMetricSenderFactory = metricSenderFactory;
return this;
}
public Builder fetchTogglesInterval(long fetchTogglesInterval) {
this.fetchTogglesInterval = fetchTogglesInterval;
return this;
}
public Builder fetchTogglesConnectTimeout(Duration connectTimeout) {
this.fetchTogglesConnectTimeout = connectTimeout;
return this;
}
public Builder fetchTogglesConnectTimeoutSeconds(long connectTimeoutSeconds) {
this.fetchTogglesConnectTimeout = Duration.ofSeconds(connectTimeoutSeconds);
return this;
}
public Builder fetchTogglesReadTimeout(Duration readTimeout) {
this.fetchTogglesReadTimeout = readTimeout;
return this;
}
public Builder fetchTogglesReadTimeoutSeconds(long readTimeoutSeconds) {
this.fetchTogglesReadTimeout = Duration.ofSeconds(readTimeoutSeconds);
return this;
}
public Builder sendMetricsInterval(long sendMetricsInterval) {
this.sendMetricsInterval = sendMetricsInterval;
return this;
}
/** * Don't poll for feature toggle updates */
public Builder disablePolling() {
this.disablePolling = true;
return this;
}
public Builder sendMetricsConnectTimeout(Duration connectTimeout) {
this.sendMetricsConnectTimeout = connectTimeout;
return this;
}
public Builder sendMetricsConnectTimeoutSeconds(long connectTimeoutSeconds) {
this.sendMetricsConnectTimeout = Duration.ofSeconds(connectTimeoutSeconds);
return this;
}
public Builder sendMetricsReadTimeout(Duration readTimeout) {
this.sendMetricsReadTimeout = readTimeout;
return this;
}
public Builder sendMetricsReadTimeoutSeconds(long readTimeoutSeconds) {
this.sendMetricsReadTimeout = Duration.ofSeconds(readTimeoutSeconds);
return this;
}
/**
* Don't send metrics to Unleash server
*
* @return
*/
public Builder disableMetrics() {
this.disableMetrics = true;
return this;
}
public Builder backupFile(String backupFile) {
this.backupFile = backupFile;
return this;
}
public Builder enableProxyAuthenticationByJvmProperties() {
this.isProxyAuthenticationByJvmProperties = true;
return this;
}
public Builder unleashContextProvider(UnleashContextProvider contextProvider) {
this.contextProvider = contextProvider;
return this;
}
public Builder synchronousFetchOnInitialisation(boolean enable) {
this.synchronousFetchOnInitialisation = enable;
return this;
}
public Builder scheduledExecutor(UnleashScheduledExecutor scheduledExecutor) {
this.scheduledExecutor = scheduledExecutor;
return this;
}
public Builder subscriber(UnleashSubscriber unleashSubscriber) {
this.unleashSubscriber = unleashSubscriber;
return this;
}
public Builder fallbackStrategy(@Nullable Strategy fallbackStrategy) {
this.fallbackStrategy = fallbackStrategy;
return this;
}
public Builder toggleBootstrapProvider(
@Nullable ToggleBootstrapProvider toggleBootstrapProvider) {
this.toggleBootstrapProvider = toggleBootstrapProvider;
return this;
}
public Builder proxy(Proxy proxy) {
this.proxy = proxy;
return this;
}
public Builder proxy(
Proxy proxy, @Nullable String proxyUser, @Nullable String proxyPassword) {
this.proxy = proxy;
if (proxyUser != null && proxyPassword != null) {
this.proxyAuthenticator =
new CustomProxyAuthenticator(proxy, proxyUser, proxyPassword);
}
return this;
}
private String getBackupFile() {
if (backupFile != null) {
return backupFile;
} else {
String fileName = "unleash-" + sanitizedAppName(appName) + "-repo.json";
String tmpDir = System.getProperty("java.io.tmpdir");
if (tmpDir == null) {
throw new IllegalStateException(
"'java.io.tmpdir' must not be empty, cause we write backup files into it.");
}
tmpDir = !tmpDir.endsWith(File.separator) ? tmpDir + File.separatorChar : tmpDir;
return tmpDir + fileName;
}
}
private String sanitizedAppName(String appName) {
if (null == appName) {
return "default";
} else if (appName.contains("/") || appName.contains("\\")) {
return appName.replace("/", "-").replace("\\", "-");
} else {
return appName;
}
}
/**
* Adds a custom http header for authorizing the client
*
* @param apiKey the client key to use to connect to the Unleash Server
* @return
*/
public Builder apiKey(String apiKey) {
this.customHttpHeaders.put("Authorization", apiKey);
return this;
}
/**
* Used to handle exceptions when starting up synchronously. Allows user the option to
* choose how errors should be handled.
*
* @param startupExceptionHandler - a lambda taking the Exception and doing what it wants to
* the system.
*/
public Builder startupExceptionHandler(
@Nullable Consumer<UnleashException> startupExceptionHandler) {
this.startupExceptionHandler = startupExceptionHandler;
return this;
}
public UnleashConfig build() {
return new UnleashConfig(
unleashAPI,
customHttpHeaders,
customHttpHeadersProvider,
appName,
environment,
instanceId,
sdkVersion,
getBackupFile(),
projectName,
namePrefix,
fetchTogglesInterval,
fetchTogglesConnectTimeout,
fetchTogglesReadTimeout,
disablePolling,
sendMetricsInterval,
sendMetricsConnectTimeout,
sendMetricsReadTimeout,
disableMetrics,
contextProvider,
isProxyAuthenticationByJvmProperties,
synchronousFetchOnInitialisation,
unleashFeatureFetcherFactory,
unleashMetricSenderFactory,
Optional.ofNullable(scheduledExecutor)
.orElseGet(UnleashScheduledExecutorImpl::getInstance),
Optional.ofNullable(unleashSubscriber).orElseGet(NoOpSubscriber::new),
fallbackStrategy,
toggleBootstrapProvider,
proxy,
proxyAuthenticator,
startupExceptionHandler);
}
public String getDefaultSdkVersion() {
String version =
Optional.ofNullable(getClass().getPackage().getImplementationVersion())
.orElse("development");
return "unleash-client-java:" + version;
}
}
}