launchdarkly-server-sdk 6.3.0 → 8.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -4
- data/lib/ldclient-rb/config.rb +112 -62
- data/lib/ldclient-rb/context.rb +444 -0
- data/lib/ldclient-rb/evaluation_detail.rb +26 -22
- data/lib/ldclient-rb/events.rb +256 -146
- data/lib/ldclient-rb/flags_state.rb +26 -15
- data/lib/ldclient-rb/impl/big_segments.rb +18 -18
- data/lib/ldclient-rb/impl/broadcaster.rb +78 -0
- data/lib/ldclient-rb/impl/context.rb +96 -0
- data/lib/ldclient-rb/impl/context_filter.rb +145 -0
- data/lib/ldclient-rb/impl/data_source.rb +188 -0
- data/lib/ldclient-rb/impl/data_store.rb +59 -0
- data/lib/ldclient-rb/impl/dependency_tracker.rb +102 -0
- data/lib/ldclient-rb/impl/diagnostic_events.rb +9 -10
- data/lib/ldclient-rb/impl/evaluator.rb +386 -142
- data/lib/ldclient-rb/impl/evaluator_bucketing.rb +40 -41
- data/lib/ldclient-rb/impl/evaluator_helpers.rb +50 -0
- data/lib/ldclient-rb/impl/evaluator_operators.rb +26 -55
- data/lib/ldclient-rb/impl/event_sender.rb +7 -6
- data/lib/ldclient-rb/impl/event_summarizer.rb +68 -0
- data/lib/ldclient-rb/impl/event_types.rb +136 -0
- data/lib/ldclient-rb/impl/flag_tracker.rb +58 -0
- data/lib/ldclient-rb/impl/integrations/consul_impl.rb +19 -7
- data/lib/ldclient-rb/impl/integrations/dynamodb_impl.rb +38 -30
- data/lib/ldclient-rb/impl/integrations/file_data_source.rb +24 -11
- data/lib/ldclient-rb/impl/integrations/redis_impl.rb +109 -12
- data/lib/ldclient-rb/impl/migrations/migrator.rb +287 -0
- data/lib/ldclient-rb/impl/migrations/tracker.rb +136 -0
- data/lib/ldclient-rb/impl/model/clause.rb +45 -0
- data/lib/ldclient-rb/impl/model/feature_flag.rb +255 -0
- data/lib/ldclient-rb/impl/model/preprocessed_data.rb +64 -0
- data/lib/ldclient-rb/impl/model/segment.rb +132 -0
- data/lib/ldclient-rb/impl/model/serialization.rb +54 -44
- data/lib/ldclient-rb/impl/repeating_task.rb +3 -4
- data/lib/ldclient-rb/impl/sampler.rb +25 -0
- data/lib/ldclient-rb/impl/store_client_wrapper.rb +102 -8
- data/lib/ldclient-rb/impl/store_data_set_sorter.rb +2 -2
- data/lib/ldclient-rb/impl/unbounded_pool.rb +1 -1
- data/lib/ldclient-rb/impl/util.rb +59 -1
- data/lib/ldclient-rb/in_memory_store.rb +9 -2
- data/lib/ldclient-rb/integrations/consul.rb +2 -2
- data/lib/ldclient-rb/integrations/dynamodb.rb +2 -2
- data/lib/ldclient-rb/integrations/file_data.rb +4 -4
- data/lib/ldclient-rb/integrations/redis.rb +5 -5
- data/lib/ldclient-rb/integrations/test_data/flag_builder.rb +287 -62
- data/lib/ldclient-rb/integrations/test_data.rb +18 -14
- data/lib/ldclient-rb/integrations/util/store_wrapper.rb +20 -9
- data/lib/ldclient-rb/interfaces.rb +600 -14
- data/lib/ldclient-rb/ldclient.rb +314 -134
- data/lib/ldclient-rb/memoized_value.rb +1 -1
- data/lib/ldclient-rb/migrations.rb +230 -0
- data/lib/ldclient-rb/non_blocking_thread_pool.rb +1 -1
- data/lib/ldclient-rb/polling.rb +52 -6
- data/lib/ldclient-rb/reference.rb +274 -0
- data/lib/ldclient-rb/requestor.rb +9 -11
- data/lib/ldclient-rb/stream.rb +96 -34
- data/lib/ldclient-rb/util.rb +97 -14
- data/lib/ldclient-rb/version.rb +1 -1
- data/lib/ldclient-rb.rb +3 -4
- metadata +65 -23
- data/lib/ldclient-rb/event_summarizer.rb +0 -55
- data/lib/ldclient-rb/file_data_source.rb +0 -23
- data/lib/ldclient-rb/impl/event_factory.rb +0 -126
- data/lib/ldclient-rb/newrelic.rb +0 -17
- data/lib/ldclient-rb/redis_store.rb +0 -88
- data/lib/ldclient-rb/user_filter.rb +0 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdb1eeb75ade6b2f82e1271c763f74ae577da09510e585b7cc1076ae9ff594d7
|
4
|
+
data.tar.gz: 8f794b216dff21125547319781efc2d77ce1632af6faccd8fa3c7fd96e2c8216
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ad1349bf430c6bb3a821d033f11106883c25d68aadc10bd622809b4c6dfe04e55ada3b9a49b8c92588389a4b3fb2112b1fd4fb63cdedf264cd3a0cc0bc0ac26
|
7
|
+
data.tar.gz: 6a605bd4f7ea9c7af3454e9a70bf5b3db1057456e5fc96249c807a706b0ca2fa8f0d3bd1238dae7e2fa5778ffe5d3b8728c9085499df0d952f76b3e41dcfa7a7
|
data/README.md
CHANGED
@@ -3,14 +3,13 @@ LaunchDarkly Server-side SDK for Ruby
|
|
3
3
|
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/launchdarkly-server-sdk.svg)](http://badge.fury.io/rb/launchdarkly-server-sdk)
|
5
5
|
|
6
|
-
[![Circle CI](https://circleci.com/gh/launchdarkly/ruby-server-sdk/tree/
|
7
|
-
[![Security](https://hakiri.io/github/launchdarkly/ruby-server-sdk/master.svg)](https://hakiri.io/github/launchdarkly/ruby-server-sdk/master)
|
6
|
+
[![Circle CI](https://circleci.com/gh/launchdarkly/ruby-server-sdk/tree/main.svg?style=svg)](https://circleci.com/gh/launchdarkly/ruby-server-sdk/tree/main)
|
8
7
|
[![RubyDoc](https://img.shields.io/static/v1?label=docs+-+all+versions&message=reference&color=00add8)](https://www.rubydoc.info/gems/launchdarkly-server-sdk)
|
9
8
|
[![GitHub Pages](https://img.shields.io/static/v1?label=docs+-+latest&message=reference&color=00add8)](https://launchdarkly.github.io/ruby-server-sdk)
|
10
9
|
|
11
10
|
LaunchDarkly overview
|
12
11
|
-------------------------
|
13
|
-
[LaunchDarkly](https://www.launchdarkly.com) is a feature management platform that serves
|
12
|
+
[LaunchDarkly](https://www.launchdarkly.com) is a feature management platform that serves trillions of feature flags daily to help teams build better software, faster. [Get started](https://docs.launchdarkly.com/home/getting-started) using LaunchDarkly today!
|
14
13
|
|
15
14
|
[![Twitter Follow](https://img.shields.io/twitter/follow/launchdarkly.svg?style=social&label=Follow&maxAge=2592000)](https://twitter.com/intent/follow?screen_name=launchdarkly)
|
16
15
|
|
@@ -27,7 +26,7 @@ Refer to the [SDK documentation](https://docs.launchdarkly.com/sdk/server-side/r
|
|
27
26
|
Learn more
|
28
27
|
-----------
|
29
28
|
|
30
|
-
|
29
|
+
Read our [documentation](http://docs.launchdarkly.com) for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the [reference guide for this SDK](http://docs.launchdarkly.com/docs/ruby-sdk-reference).
|
31
30
|
|
32
31
|
Generated API documentation for all versions of the SDK is on [RubyDoc.info](https://www.rubydoc.info/gems/launchdarkly-server-sdk). The API documentation for the latest version is also on [GitHub Pages](https://launchdarkly.github.io/ruby-server-sdk).
|
33
32
|
|
data/lib/ldclient-rb/config.rb
CHANGED
@@ -21,6 +21,7 @@ module LaunchDarkly
|
|
21
21
|
# @option opts [Integer] :capacity (10000) See {#capacity}.
|
22
22
|
# @option opts [Float] :flush_interval (30) See {#flush_interval}.
|
23
23
|
# @option opts [Float] :read_timeout (10) See {#read_timeout}.
|
24
|
+
# @option opts [Float] :initial_reconnect_delay (1) See {#initial_reconnect_delay}.
|
24
25
|
# @option opts [Float] :connect_timeout (2) See {#connect_timeout}.
|
25
26
|
# @option opts [Object] :cache_store See {#cache_store}.
|
26
27
|
# @option opts [Object] :feature_store See {#feature_store}.
|
@@ -29,20 +30,19 @@ module LaunchDarkly
|
|
29
30
|
# @option opts [Float] :poll_interval (30) See {#poll_interval}.
|
30
31
|
# @option opts [Boolean] :stream (true) See {#stream?}.
|
31
32
|
# @option opts [Boolean] all_attributes_private (false) See {#all_attributes_private}.
|
32
|
-
# @option opts [Array] :
|
33
|
+
# @option opts [Array] :private_attributes See {#private_attributes}.
|
33
34
|
# @option opts [Boolean] :send_events (true) See {#send_events}.
|
34
|
-
# @option opts [Integer] :
|
35
|
-
# @option opts [Float] :
|
36
|
-
# @option opts [Boolean] :inline_users_in_events (false) See {#inline_users_in_events}.
|
35
|
+
# @option opts [Integer] :context_keys_capacity (1000) See {#context_keys_capacity}.
|
36
|
+
# @option opts [Float] :context_keys_flush_interval (300) See {#context_keys_flush_interval}.
|
37
37
|
# @option opts [Object] :data_source See {#data_source}.
|
38
|
-
# @option opts [Object] :update_processor Obsolete synonym for `data_source`.
|
39
|
-
# @option opts [Object] :update_processor_factory Obsolete synonym for `data_source`.
|
40
38
|
# @option opts [Boolean] :diagnostic_opt_out (false) See {#diagnostic_opt_out?}.
|
41
39
|
# @option opts [Float] :diagnostic_recording_interval (900) See {#diagnostic_recording_interval}.
|
42
40
|
# @option opts [String] :wrapper_name See {#wrapper_name}.
|
43
41
|
# @option opts [String] :wrapper_version See {#wrapper_version}.
|
44
42
|
# @option opts [#open] :socket_factory See {#socket_factory}.
|
45
43
|
# @option opts [BigSegmentsConfig] :big_segments See {#big_segments}.
|
44
|
+
# @option opts [Hash] :application See {#application}
|
45
|
+
# @option opts [String] :payload_filter_key See {#payload_filter_key}
|
46
46
|
#
|
47
47
|
def initialize(opts = {})
|
48
48
|
@base_uri = (opts[:base_uri] || Config.default_base_uri).chomp("/")
|
@@ -54,20 +54,18 @@ module LaunchDarkly
|
|
54
54
|
@flush_interval = opts[:flush_interval] || Config.default_flush_interval
|
55
55
|
@connect_timeout = opts[:connect_timeout] || Config.default_connect_timeout
|
56
56
|
@read_timeout = opts[:read_timeout] || Config.default_read_timeout
|
57
|
+
@initial_reconnect_delay = opts[:initial_reconnect_delay] || Config.default_initial_reconnect_delay
|
57
58
|
@feature_store = opts[:feature_store] || Config.default_feature_store
|
58
59
|
@stream = opts.has_key?(:stream) ? opts[:stream] : Config.default_stream
|
59
60
|
@use_ldd = opts.has_key?(:use_ldd) ? opts[:use_ldd] : Config.default_use_ldd
|
60
61
|
@offline = opts.has_key?(:offline) ? opts[:offline] : Config.default_offline
|
61
62
|
@poll_interval = opts.has_key?(:poll_interval) && opts[:poll_interval] > Config.default_poll_interval ? opts[:poll_interval] : Config.default_poll_interval
|
62
63
|
@all_attributes_private = opts[:all_attributes_private] || false
|
63
|
-
@
|
64
|
+
@private_attributes = opts[:private_attributes] || []
|
64
65
|
@send_events = opts.has_key?(:send_events) ? opts[:send_events] : Config.default_send_events
|
65
|
-
@
|
66
|
-
@
|
67
|
-
@
|
68
|
-
@data_source = opts[:data_source] || opts[:update_processor] || opts[:update_processor_factory]
|
69
|
-
@update_processor = opts[:update_processor]
|
70
|
-
@update_processor_factory = opts[:update_processor_factory]
|
66
|
+
@context_keys_capacity = opts[:context_keys_capacity] || Config.default_context_keys_capacity
|
67
|
+
@context_keys_flush_interval = opts[:context_keys_flush_interval] || Config.default_context_keys_flush_interval
|
68
|
+
@data_source = opts[:data_source]
|
71
69
|
@diagnostic_opt_out = opts.has_key?(:diagnostic_opt_out) && opts[:diagnostic_opt_out]
|
72
70
|
@diagnostic_recording_interval = opts.has_key?(:diagnostic_recording_interval) && opts[:diagnostic_recording_interval] > Config.minimum_diagnostic_recording_interval ?
|
73
71
|
opts[:diagnostic_recording_interval] : Config.default_diagnostic_recording_interval
|
@@ -75,8 +73,25 @@ module LaunchDarkly
|
|
75
73
|
@wrapper_version = opts[:wrapper_version]
|
76
74
|
@socket_factory = opts[:socket_factory]
|
77
75
|
@big_segments = opts[:big_segments] || BigSegmentsConfig.new(store: nil)
|
76
|
+
@application = LaunchDarkly::Impl::Util.validate_application_info(opts[:application] || {}, @logger)
|
77
|
+
@payload_filter_key = opts[:payload_filter_key]
|
78
|
+
@data_source_update_sink = nil
|
78
79
|
end
|
79
80
|
|
81
|
+
#
|
82
|
+
# Returns the component that allows a data source to push data into the SDK.
|
83
|
+
#
|
84
|
+
# This property should only be set by the SDK. Long term access of this
|
85
|
+
# property is not supported; it is temporarily being exposed to maintain
|
86
|
+
# backwards compatibility while the SDK structure is updated.
|
87
|
+
#
|
88
|
+
# Custom data source implementations should integrate with this sink if
|
89
|
+
# they want to provide support for data source status listeners.
|
90
|
+
#
|
91
|
+
# @private
|
92
|
+
#
|
93
|
+
attr_accessor :data_source_update_sink
|
94
|
+
|
80
95
|
#
|
81
96
|
# The base URL for the LaunchDarkly server. This is configurable mainly for testing
|
82
97
|
# purposes; most users should use the default value.
|
@@ -122,7 +137,7 @@ module LaunchDarkly
|
|
122
137
|
def use_ldd?
|
123
138
|
@use_ldd
|
124
139
|
end
|
125
|
-
|
140
|
+
|
126
141
|
#
|
127
142
|
# Whether the client should be initialized in offline mode. In offline mode, default values are
|
128
143
|
# returned for all flags and no remote network requests are made.
|
@@ -180,6 +195,13 @@ module LaunchDarkly
|
|
180
195
|
#
|
181
196
|
attr_reader :read_timeout
|
182
197
|
|
198
|
+
#
|
199
|
+
# The initial delay before reconnecting after an error in the SSE client.
|
200
|
+
# This only applies to the streaming connection.
|
201
|
+
# @return [Float]
|
202
|
+
#
|
203
|
+
attr_reader :initial_reconnect_delay
|
204
|
+
|
183
205
|
#
|
184
206
|
# The connect timeout for network connections in seconds.
|
185
207
|
# @return [Float]
|
@@ -198,28 +220,29 @@ module LaunchDarkly
|
|
198
220
|
attr_reader :feature_store
|
199
221
|
|
200
222
|
#
|
201
|
-
# True if all
|
223
|
+
# True if all context attributes (other than the key) should be considered private. This means
|
202
224
|
# that the attribute values will not be sent to LaunchDarkly in analytics events and will not
|
203
225
|
# appear on the LaunchDarkly dashboard.
|
204
226
|
# @return [Boolean]
|
205
|
-
# @see #
|
227
|
+
# @see #private_attributes
|
206
228
|
#
|
207
229
|
attr_reader :all_attributes_private
|
208
230
|
|
209
231
|
#
|
210
|
-
# A list of
|
232
|
+
# A list of context attribute names that should always be considered private. This means that the
|
211
233
|
# attribute values will not be sent to LaunchDarkly in analytics events and will not appear on
|
212
234
|
# the LaunchDarkly dashboard.
|
213
235
|
#
|
214
|
-
# You can also specify the same behavior for an individual flag evaluation
|
215
|
-
#
|
216
|
-
#
|
236
|
+
# You can also specify the same behavior for an individual flag evaluation
|
237
|
+
# by providing the context object with a list of private attributes.
|
238
|
+
#
|
239
|
+
# @see https://docs.launchdarkly.com/sdk/features/user-context-config#using-private-attributes
|
217
240
|
#
|
218
241
|
# @return [Array<String>]
|
219
242
|
# @see #all_attributes_private
|
220
243
|
#
|
221
|
-
attr_reader :
|
222
|
-
|
244
|
+
attr_reader :private_attributes
|
245
|
+
|
223
246
|
#
|
224
247
|
# Whether to send events back to LaunchDarkly. This differs from {#offline?} in that it affects
|
225
248
|
# only the sending of client-side events, not streaming or polling for events from the server.
|
@@ -228,27 +251,19 @@ module LaunchDarkly
|
|
228
251
|
attr_reader :send_events
|
229
252
|
|
230
253
|
#
|
231
|
-
# The number of
|
232
|
-
# amount of duplicate
|
254
|
+
# The number of context keys that the event processor can remember at any one time. This reduces the
|
255
|
+
# amount of duplicate context details sent in analytics events.
|
233
256
|
# @return [Integer]
|
234
|
-
# @see #
|
257
|
+
# @see #context_keys_flush_interval
|
235
258
|
#
|
236
|
-
attr_reader :
|
259
|
+
attr_reader :context_keys_capacity
|
237
260
|
|
238
261
|
#
|
239
|
-
# The interval in seconds at which the event processor will reset its set of known
|
262
|
+
# The interval in seconds at which the event processor will reset its set of known context keys.
|
240
263
|
# @return [Float]
|
241
|
-
# @see #
|
242
|
-
#
|
243
|
-
attr_reader :user_keys_flush_interval
|
244
|
-
|
245
|
-
#
|
246
|
-
# Whether to include full user details in every analytics event. By default, events will only
|
247
|
-
# include the user key, except for one "index" event that provides the full details for the user.
|
248
|
-
# The only reason to change this is if you are using the Analytics Data Stream.
|
249
|
-
# @return [Boolean]
|
264
|
+
# @see #context_keys_capacity
|
250
265
|
#
|
251
|
-
attr_reader :
|
266
|
+
attr_reader :context_keys_flush_interval
|
252
267
|
|
253
268
|
#
|
254
269
|
# An object that is responsible for receiving feature flag data from LaunchDarkly. By default,
|
@@ -268,18 +283,45 @@ module LaunchDarkly
|
|
268
283
|
#
|
269
284
|
# Configuration options related to Big Segments.
|
270
285
|
#
|
271
|
-
# Big Segments are a specific type of
|
286
|
+
# Big Segments are a specific type of segments. For more information, read the LaunchDarkly
|
272
287
|
# documentation: https://docs.launchdarkly.com/home/users/big-segments
|
273
288
|
#
|
274
289
|
# @return [BigSegmentsConfig]
|
275
290
|
#
|
276
291
|
attr_reader :big_segments
|
277
292
|
|
278
|
-
#
|
279
|
-
|
280
|
-
|
281
|
-
#
|
282
|
-
|
293
|
+
#
|
294
|
+
# An object that allows configuration of application metadata.
|
295
|
+
#
|
296
|
+
# Application metadata may be used in LaunchDarkly analytics or other product features, but does not affect feature flag evaluations.
|
297
|
+
#
|
298
|
+
# If you want to set non-default values for any of these fields, provide the appropriately configured hash to the {Config} object.
|
299
|
+
#
|
300
|
+
# @example Configuring application information
|
301
|
+
# opts[:application] = {
|
302
|
+
# id: "MY APPLICATION ID",
|
303
|
+
# version: "MY APPLICATION VERSION"
|
304
|
+
# }
|
305
|
+
# config = LDConfig.new(opts)
|
306
|
+
#
|
307
|
+
# @return [Hash]
|
308
|
+
#
|
309
|
+
attr_reader :application
|
310
|
+
|
311
|
+
#
|
312
|
+
# LaunchDarkly Server SDKs historically downloaded all flag configuration and segments for a particular environment
|
313
|
+
# during initialization.
|
314
|
+
#
|
315
|
+
# For some customers, this is an unacceptably large amount of data, and has contributed to performance issues within
|
316
|
+
# their products.
|
317
|
+
#
|
318
|
+
# Filtered environments aim to solve this problem. By allowing customers to specify subsets of an environment's
|
319
|
+
# flags using a filter key, SDKs will initialize faster and use less memory.
|
320
|
+
#
|
321
|
+
# This payload filter key only applies to the default streaming and polling data sources. It will not affect TestData or FileData
|
322
|
+
# data sources, nor will it be applied to any data source provided through the {#data_source} config property.
|
323
|
+
#
|
324
|
+
attr_reader :payload_filter_key
|
283
325
|
|
284
326
|
#
|
285
327
|
# Set to true to opt out of sending diagnostics data.
|
@@ -395,9 +437,17 @@ module LaunchDarkly
|
|
395
437
|
10
|
396
438
|
end
|
397
439
|
|
440
|
+
#
|
441
|
+
# The default value for {#initial_reconnect_delay}.
|
442
|
+
# @return [Float] 1
|
443
|
+
#
|
444
|
+
def self.default_initial_reconnect_delay
|
445
|
+
1
|
446
|
+
end
|
447
|
+
|
398
448
|
#
|
399
449
|
# The default value for {#connect_timeout}.
|
400
|
-
# @return [Float]
|
450
|
+
# @return [Float] 2
|
401
451
|
#
|
402
452
|
def self.default_connect_timeout
|
403
453
|
2
|
@@ -409,8 +459,8 @@ module LaunchDarkly
|
|
409
459
|
#
|
410
460
|
def self.default_logger
|
411
461
|
if defined?(Rails) && Rails.respond_to?(:logger)
|
412
|
-
Rails.logger
|
413
|
-
else
|
462
|
+
Rails.logger
|
463
|
+
else
|
414
464
|
log = ::Logger.new($stdout)
|
415
465
|
log.level = ::Logger::WARN
|
416
466
|
log
|
@@ -466,18 +516,18 @@ module LaunchDarkly
|
|
466
516
|
end
|
467
517
|
|
468
518
|
#
|
469
|
-
# The default value for {#
|
519
|
+
# The default value for {#context_keys_capacity}.
|
470
520
|
# @return [Integer] 1000
|
471
521
|
#
|
472
|
-
def self.
|
522
|
+
def self.default_context_keys_capacity
|
473
523
|
1000
|
474
524
|
end
|
475
525
|
|
476
526
|
#
|
477
|
-
# The default value for {#
|
527
|
+
# The default value for {#context_keys_flush_interval}.
|
478
528
|
# @return [Float] 300
|
479
529
|
#
|
480
|
-
def self.
|
530
|
+
def self.default_context_keys_flush_interval
|
481
531
|
300
|
482
532
|
end
|
483
533
|
|
@@ -501,7 +551,7 @@ module LaunchDarkly
|
|
501
551
|
#
|
502
552
|
# Configuration options related to Big Segments.
|
503
553
|
#
|
504
|
-
# Big Segments are a specific type of
|
554
|
+
# Big Segments are a specific type of segments. For more information, read the LaunchDarkly
|
505
555
|
# documentation: https://docs.launchdarkly.com/home/users/big-segments
|
506
556
|
#
|
507
557
|
# If your application uses Big Segments, you will need to create a `BigSegmentsConfig` that at a
|
@@ -515,8 +565,8 @@ module LaunchDarkly
|
|
515
565
|
# client = LaunchDarkly::LDClient.new(my_sdk_key, config)
|
516
566
|
#
|
517
567
|
class BigSegmentsConfig
|
518
|
-
|
519
|
-
|
568
|
+
DEFAULT_CONTEXT_CACHE_SIZE = 1000
|
569
|
+
DEFAULT_CONTEXT_CACHE_TIME = 5
|
520
570
|
DEFAULT_STATUS_POLL_INTERVAL = 5
|
521
571
|
DEFAULT_STALE_AFTER = 2 * 60
|
522
572
|
|
@@ -524,15 +574,15 @@ module LaunchDarkly
|
|
524
574
|
# Constructor for setting Big Segments options.
|
525
575
|
#
|
526
576
|
# @param store [LaunchDarkly::Interfaces::BigSegmentStore] the data store implementation
|
527
|
-
# @param
|
528
|
-
# @param
|
577
|
+
# @param context_cache_size [Integer] See {#context_cache_size}.
|
578
|
+
# @param context_cache_time [Float] See {#context_cache_time}.
|
529
579
|
# @param status_poll_interval [Float] See {#status_poll_interval}.
|
530
580
|
# @param stale_after [Float] See {#stale_after}.
|
531
581
|
#
|
532
|
-
def initialize(store:,
|
582
|
+
def initialize(store:, context_cache_size: nil, context_cache_time: nil, status_poll_interval: nil, stale_after: nil)
|
533
583
|
@store = store
|
534
|
-
@
|
535
|
-
@
|
584
|
+
@context_cache_size = context_cache_size.nil? ? DEFAULT_CONTEXT_CACHE_SIZE : context_cache_size
|
585
|
+
@context_cache_time = context_cache_time.nil? ? DEFAULT_CONTEXT_CACHE_TIME : context_cache_time
|
536
586
|
@status_poll_interval = status_poll_interval.nil? ? DEFAULT_STATUS_POLL_INTERVAL : status_poll_interval
|
537
587
|
@stale_after = stale_after.nil? ? DEFAULT_STALE_AFTER : stale_after
|
538
588
|
end
|
@@ -542,14 +592,14 @@ module LaunchDarkly
|
|
542
592
|
# @return [LaunchDarkly::Interfaces::BigSegmentStore]
|
543
593
|
attr_reader :store
|
544
594
|
|
545
|
-
# The maximum number of
|
595
|
+
# The maximum number of contexts whose Big Segment state will be cached by the SDK at any given time.
|
546
596
|
# @return [Integer]
|
547
|
-
attr_reader :
|
597
|
+
attr_reader :context_cache_size
|
548
598
|
|
549
|
-
# The maximum length of time (in seconds) that the Big Segment state for a
|
599
|
+
# The maximum length of time (in seconds) that the Big Segment state for a context will be cached
|
550
600
|
# by the SDK.
|
551
601
|
# @return [Float]
|
552
|
-
attr_reader :
|
602
|
+
attr_reader :context_cache_time
|
553
603
|
|
554
604
|
# The interval (in seconds) at which the SDK will poll the Big Segment store to make sure it is
|
555
605
|
# available and to determine how long ago it was updated.
|