-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDevCycleLocalOptions.java
More file actions
123 lines (102 loc) · 5.09 KB
/
DevCycleLocalOptions.java
File metadata and controls
123 lines (102 loc) · 5.09 KB
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
package com.devcycle.sdk.server.local.model;
import com.devcycle.sdk.server.common.api.IRestOptions;
import com.devcycle.sdk.server.common.logging.DevCycleLogger;
import com.devcycle.sdk.server.common.logging.IDevCycleLogger;
import com.devcycle.sdk.server.common.model.EvalHook;
import com.devcycle.sdk.server.common.model.IDevCycleOptions;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Builder;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class DevCycleLocalOptions implements IDevCycleOptions {
private int configRequestTimeoutMs = 10000;
private int configPollingIntervalMS = 30000;
private String configCdnBaseUrl = "https://config-cdn.devcycle.com/";
private String eventsApiBaseUrl = "https://events.devcycle.com/";
private int eventFlushIntervalMS = 10000;
private int flushEventQueueSize = 1000;
private int maxEventQueueSize = 2000;
private int eventRequestChunkSize = 100;
private boolean disableAutomaticEventLogging = false;
private boolean disableRealtimeUpdates = false;
/**
* @deprecated real time updates are enabled by default now
*/
@Deprecated
private boolean enableBetaRealtimeUpdates = false;
@JsonIgnore
private IDevCycleLogger customLogger = null;
private boolean disableCustomEventLogging = false;
@JsonIgnore
private IRestOptions restOptions = null;
@JsonIgnore
private List<EvalHook> hooks = new ArrayList<>();
@Builder()
public DevCycleLocalOptions(
int configRequestTimeoutMs,
@Deprecated
int configPollingIntervalMs,
int configPollingIntervalMS,
String configCdnBaseUrl,
String eventsApiBaseUrl,
int eventFlushIntervalMS,
int flushEventQueueSize,
int maxEventQueueSize,
int eventRequestChunkSize,
boolean disableAutomaticEventLogging,
boolean disableCustomEventLogging,
IDevCycleLogger customLogger,
IRestOptions restOptions,
@Deprecated
boolean enableBetaRealtimeUpdates,
boolean disableRealtimeUpdates,
List<EvalHook> hooks
) {
this.configRequestTimeoutMs = configRequestTimeoutMs > 0 ? configRequestTimeoutMs : this.configRequestTimeoutMs;
this.configPollingIntervalMS = getConfigPollingIntervalMS(configPollingIntervalMs, configPollingIntervalMS);
this.configCdnBaseUrl = configCdnBaseUrl != null ? configCdnBaseUrl : this.configCdnBaseUrl;
this.eventsApiBaseUrl = eventsApiBaseUrl != null ? eventsApiBaseUrl : this.eventsApiBaseUrl;
this.eventFlushIntervalMS = eventFlushIntervalMS > 0 ? eventFlushIntervalMS : this.eventFlushIntervalMS;
this.flushEventQueueSize = flushEventQueueSize > 0 ? flushEventQueueSize : this.flushEventQueueSize;
this.maxEventQueueSize = maxEventQueueSize > 0 ? maxEventQueueSize : this.maxEventQueueSize;
this.eventRequestChunkSize = eventRequestChunkSize > 0 ? eventRequestChunkSize : this.eventRequestChunkSize;
this.disableAutomaticEventLogging = disableAutomaticEventLogging;
this.disableCustomEventLogging = disableCustomEventLogging;
this.customLogger = customLogger;
this.restOptions = restOptions;
this.enableBetaRealtimeUpdates = enableBetaRealtimeUpdates;
this.disableRealtimeUpdates = disableRealtimeUpdates;
this.hooks = hooks;
if (this.flushEventQueueSize >= this.maxEventQueueSize) {
DevCycleLogger.warning("flushEventQueueSize: " + this.flushEventQueueSize + " must be smaller than maxEventQueueSize: " + this.maxEventQueueSize);
this.flushEventQueueSize = this.maxEventQueueSize - 1;
}
if (this.eventRequestChunkSize > this.flushEventQueueSize) {
DevCycleLogger.warning("eventRequestChunkSize: " + this.eventRequestChunkSize + " must be smaller than flushEventQueueSize: " + this.flushEventQueueSize);
this.eventRequestChunkSize = 100;
}
if (this.eventRequestChunkSize > this.maxEventQueueSize) {
DevCycleLogger.warning("eventRequestChunkSize: " + this.eventRequestChunkSize + " must be smaller than maxEventQueueSize: " + this.maxEventQueueSize);
this.eventRequestChunkSize = 100;
}
if (this.flushEventQueueSize > 20000) {
DevCycleLogger.warning("flushEventQueueSize: " + this.flushEventQueueSize + " must be smaller than 20,000");
this.flushEventQueueSize = 20000;
}
if (this.maxEventQueueSize > 20000) {
DevCycleLogger.warning("maxEventQueueSize: " + this.maxEventQueueSize + " must be smaller than 20,000");
this.maxEventQueueSize = 20000;
}
}
public int getConfigPollingIntervalMS(int configPollingIntervalMs, int configPollingIntervalMS) {
if (configPollingIntervalMS > 0) {
return configPollingIntervalMS;
} else if (configPollingIntervalMs > 0) {
return configPollingIntervalMs;
} else {
return this.configPollingIntervalMS;
}
}
}