13
13
import lombok .Builder ;
14
14
import lombok .Getter ;
15
15
16
- /** FlagdOptions is a builder to build flagd provider options. */
16
+ /**
17
+ * FlagdOptions is a builder to build flagd provider options.
18
+ */
17
19
@ Builder
18
20
@ Getter
19
21
@ SuppressWarnings ("PMD.TooManyStaticImports" )
20
22
public class FlagdOptions {
21
23
22
- /** flagd resolving type. */
24
+ /**
25
+ * flagd resolving type.
26
+ */
23
27
private Config .EvaluatorType resolverType ;
24
28
25
- /** flagd connection host. */
29
+ /**
30
+ * flagd connection host.
31
+ */
26
32
@ Builder .Default
27
33
private String host = fallBackToEnvOrDefault (Config .HOST_ENV_VAR_NAME , Config .DEFAULT_HOST );
28
34
29
- /** flagd connection port. */
35
+ /**
36
+ * flagd connection port.
37
+ */
30
38
private int port ;
31
39
32
- /** Use TLS connectivity. */
40
+ /**
41
+ * Use TLS connectivity.
42
+ */
33
43
@ Builder .Default
34
44
private boolean tls = Boolean .parseBoolean (fallBackToEnvOrDefault (Config .TLS_ENV_VAR_NAME , Config .DEFAULT_TLS ));
35
45
36
- /** TLS certificate overriding if TLS connectivity is used. */
46
+ /**
47
+ * TLS certificate overriding if TLS connectivity is used.
48
+ */
37
49
@ Builder .Default
38
50
private String certPath = fallBackToEnvOrDefault (Config .SERVER_CERT_PATH_ENV_VAR_NAME , null );
39
51
40
- /** Unix socket path to flagd. */
52
+ /**
53
+ * Unix socket path to flagd.
54
+ */
41
55
@ Builder .Default
42
56
private String socketPath = fallBackToEnvOrDefault (Config .SOCKET_PATH_ENV_VAR_NAME , null );
43
57
44
- /** Cache type to use. Supports - lru, disabled. */
58
+ /**
59
+ * Cache type to use. Supports - lru, disabled.
60
+ */
45
61
@ Builder .Default
46
62
private String cacheType = fallBackToEnvOrDefault (Config .CACHE_ENV_VAR_NAME , Config .DEFAULT_CACHE );
47
63
48
- /** Max cache size. */
64
+ /**
65
+ * Max cache size.
66
+ */
49
67
@ Builder .Default
50
68
private int maxCacheSize =
51
69
fallBackToEnvOrDefault (Config .MAX_CACHE_SIZE_ENV_VAR_NAME , Config .DEFAULT_MAX_CACHE_SIZE );
52
70
53
- /** Max event stream connection retries. */
54
- @ Builder .Default
55
- private int maxEventStreamRetries = fallBackToEnvOrDefault (
56
- Config .MAX_EVENT_STREAM_RETRIES_ENV_VAR_NAME , Config .DEFAULT_MAX_EVENT_STREAM_RETRIES );
57
-
58
- /** Backoff interval in milliseconds. */
71
+ /**
72
+ * Backoff interval in milliseconds.
73
+ */
59
74
@ Builder .Default
60
75
private int retryBackoffMs = fallBackToEnvOrDefault (
61
76
Config .BASE_EVENT_STREAM_RETRY_BACKOFF_MS_ENV_VAR_NAME , Config .BASE_EVENT_STREAM_RETRY_BACKOFF_MS );
62
77
63
78
/**
64
- * Connection deadline in milliseconds. For RPC resolving, this is the deadline to connect to
65
- * flagd for flag evaluation. For in-process resolving, this is the deadline for sync stream
66
- * termination.
79
+ * Connection deadline in milliseconds.
80
+ * For RPC resolving, this is the deadline to connect to flagd for flag
81
+ * evaluation.
82
+ * For in-process resolving, this is the deadline for sync stream termination.
67
83
*/
68
84
@ Builder .Default
69
85
private int deadline = fallBackToEnvOrDefault (Config .DEADLINE_MS_ENV_VAR_NAME , Config .DEFAULT_DEADLINE );
70
86
71
87
/**
72
- * Streaming connection deadline in milliseconds. Set to 0 to disable the deadline. Defaults to
73
- * 600000 (10 minutes); recommended to prevent infrastructure from killing idle connections.
88
+ * Streaming connection deadline in milliseconds.
89
+ * Set to 0 to disable the deadline.
90
+ * Defaults to 600000 (10 minutes); recommended to prevent infrastructure from killing idle connections.
74
91
*/
75
92
@ Builder .Default
76
93
private int streamDeadlineMs =
77
94
fallBackToEnvOrDefault (Config .STREAM_DEADLINE_MS_ENV_VAR_NAME , Config .DEFAULT_STREAM_DEADLINE_MS );
78
95
79
- /** Selector to be used with flag sync gRPC contract. */
96
+ /**
97
+ * Grace time period in seconds before provider moves from STALE to ERROR.
98
+ * Defaults to 5
99
+ */
100
+ @ Builder .Default
101
+ private int retryGracePeriod =
102
+ fallBackToEnvOrDefault (Config .STREAM_RETRY_GRACE_PERIOD , Config .DEFAULT_STREAM_RETRY_GRACE_PERIOD );
103
+ /**
104
+ * Selector to be used with flag sync gRPC contract.
105
+ **/
80
106
@ Builder .Default
81
107
private String selector = fallBackToEnvOrDefault (Config .SOURCE_SELECTOR_ENV_VAR_NAME , null );
82
108
83
- /** gRPC client KeepAlive in milliseconds. Disabled with 0. Defaults to 0 (disabled). */
109
+ /**
110
+ * gRPC client KeepAlive in milliseconds. Disabled with 0.
111
+ * Defaults to 0 (disabled).
112
+ **/
84
113
@ Builder .Default
85
114
private long keepAlive = fallBackToEnvOrDefault (
86
115
Config .KEEP_ALIVE_MS_ENV_VAR_NAME ,
87
116
fallBackToEnvOrDefault (Config .KEEP_ALIVE_MS_ENV_VAR_NAME_OLD , Config .DEFAULT_KEEP_ALIVE ));
88
117
89
118
/**
90
- * File source of flags to be used by offline mode. Setting this enables the offline mode of the
91
- * in-process provider.
119
+ * File source of flags to be used by offline mode.
120
+ * Setting this enables the offline mode of the in-process provider.
92
121
*/
93
122
@ Builder .Default
94
123
private String offlineFlagSourcePath = fallBackToEnvOrDefault (Config .OFFLINE_SOURCE_PATH , null );
95
124
96
125
/**
97
126
* gRPC custom target string.
98
127
*
99
- * <p>Setting this will allow user to use custom gRPC name resolver at present we are supporting
100
- * all core resolver along with a custom resolver for envoy proxy resolution. For more visit
101
- * (https://grpc.io/docs/guides/custom-name-resolution/)
128
+ * <p>Setting this will allow user to use custom gRPC name resolver at present
129
+ * we are supporting all core resolver along with a custom resolver for envoy proxy
130
+ * resolution. For more visit (https://grpc.io/docs/guides/custom-name-resolution/)
102
131
*/
103
132
@ Builder .Default
104
133
private String targetUri = fallBackToEnvOrDefault (Config .TARGET_URI_ENV_VAR_NAME , null );
105
134
106
135
/**
107
- * Function providing an EvaluationContext to mix into every evaluations. The sync-metadata
108
- * response
136
+ * Function providing an EvaluationContext to mix into every evaluations.
137
+ * The sync-metadata response
109
138
* (https://buf.build/open-feature/flagd/docs/main:flagd.sync.v1#flagd.sync.v1.GetMetadataResponse),
110
- * represented as a {@link dev.openfeature.sdk.Structure}, is passed as an argument. This function
111
- * runs every time the provider (re)connects, and its result is cached and used in every
112
- * evaluation. By default, the entire sync response (converted to a Structure) is used.
139
+ * represented as a {@link dev.openfeature.sdk.Structure}, is passed as an
140
+ * argument.
141
+ * This function runs every time the provider (re)connects, and its result is cached and used in every evaluation.
142
+ * By default, the entire sync response (converted to a Structure) is used.
113
143
*/
114
144
@ Builder .Default
115
145
private Function <Structure , EvaluationContext > contextEnricher =
116
146
(syncMetadata ) -> new ImmutableContext (syncMetadata .asMap ());
117
147
118
- /** Inject a Custom Connector for fetching flags. */
148
+ /**
149
+ * Inject a Custom Connector for fetching flags.
150
+ */
119
151
private Connector customConnector ;
120
152
121
153
/**
122
- * Inject OpenTelemetry for the library runtime. Providing sdk will initiate distributed tracing
123
- * for flagd grpc connectivity.
154
+ * Inject OpenTelemetry for the library runtime. Providing sdk will initiate
155
+ * distributed tracing for flagd grpc
156
+ * connectivity.
124
157
*/
125
158
private OpenTelemetry openTelemetry ;
126
159
@@ -139,11 +172,14 @@ public FlagdOptions build() {
139
172
};
140
173
}
141
174
142
- /** Overload default lombok builder. */
175
+ /**
176
+ * Overload default lombok builder.
177
+ */
143
178
public static class FlagdOptionsBuilder {
144
179
/**
145
- * Enable OpenTelemetry instance extraction from GlobalOpenTelemetry. Note that, this is only
146
- * useful if global configurations are registered.
180
+ * Enable OpenTelemetry instance extraction from GlobalOpenTelemetry. Note that,
181
+ * this is only useful if global
182
+ * configurations are registered.
147
183
*/
148
184
public FlagdOptionsBuilder withGlobalTelemetry (final boolean b ) {
149
185
if (b ) {
0 commit comments