launchdarkly-server-sdk 6.3.4 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ldclient-rb/config.rb +121 -55
- data/lib/ldclient-rb/context.rb +487 -0
- data/lib/ldclient-rb/evaluation_detail.rb +20 -20
- data/lib/ldclient-rb/events.rb +77 -132
- data/lib/ldclient-rb/flags_state.rb +4 -4
- data/lib/ldclient-rb/impl/big_segments.rb +17 -17
- data/lib/ldclient-rb/impl/context.rb +96 -0
- data/lib/ldclient-rb/impl/context_filter.rb +145 -0
- data/lib/ldclient-rb/impl/diagnostic_events.rb +9 -10
- data/lib/ldclient-rb/impl/evaluator.rb +378 -139
- 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 +6 -6
- data/lib/ldclient-rb/impl/event_summarizer.rb +12 -7
- data/lib/ldclient-rb/impl/event_types.rb +18 -30
- data/lib/ldclient-rb/impl/integrations/consul_impl.rb +7 -7
- data/lib/ldclient-rb/impl/integrations/dynamodb_impl.rb +29 -29
- data/lib/ldclient-rb/impl/integrations/file_data_source.rb +8 -8
- data/lib/ldclient-rb/impl/integrations/redis_impl.rb +92 -12
- data/lib/ldclient-rb/impl/model/clause.rb +39 -0
- data/lib/ldclient-rb/impl/model/feature_flag.rb +213 -0
- data/lib/ldclient-rb/impl/model/preprocessed_data.rb +64 -0
- data/lib/ldclient-rb/impl/model/segment.rb +126 -0
- data/lib/ldclient-rb/impl/model/serialization.rb +54 -44
- data/lib/ldclient-rb/impl/repeating_task.rb +1 -1
- 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 +2 -2
- data/lib/ldclient-rb/integrations/consul.rb +1 -1
- data/lib/ldclient-rb/integrations/dynamodb.rb +1 -1
- data/lib/ldclient-rb/integrations/file_data.rb +3 -3
- data/lib/ldclient-rb/integrations/redis.rb +4 -4
- data/lib/ldclient-rb/integrations/test_data/flag_builder.rb +218 -62
- data/lib/ldclient-rb/integrations/test_data.rb +16 -12
- data/lib/ldclient-rb/integrations/util/store_wrapper.rb +9 -9
- data/lib/ldclient-rb/interfaces.rb +14 -14
- data/lib/ldclient-rb/ldclient.rb +94 -144
- data/lib/ldclient-rb/memoized_value.rb +1 -1
- data/lib/ldclient-rb/non_blocking_thread_pool.rb +1 -1
- data/lib/ldclient-rb/polling.rb +2 -2
- data/lib/ldclient-rb/reference.rb +274 -0
- data/lib/ldclient-rb/requestor.rb +7 -7
- data/lib/ldclient-rb/stream.rb +8 -9
- data/lib/ldclient-rb/util.rb +4 -19
- data/lib/ldclient-rb/version.rb +1 -1
- data/lib/ldclient-rb.rb +2 -3
- metadata +36 -17
- data/lib/ldclient-rb/file_data_source.rb +0 -23
- 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: e189d76d654dbf73dc95e9cea758b81bc0df93d9012ebb6560d0994e6dff227c
|
4
|
+
data.tar.gz: fc8bdc8b9affee0e51ef233c217cfa4a3c7fbdbceb4694c38c5a2e90155205ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fb89d48c3185f7019cd170f36f571b1ca2f7de130c624d6301fbfd30d46a0ae7a986494393ab290fa23b66511ce676b660533e1ad23d3a9e01fb037e20db6c4
|
7
|
+
data.tar.gz: 7e706747d2fcd1ab299a76eca7bf26908dbe97972b8c1ea74cfae6bc6aaffe866ddfc157b26675eb44fb22044c74efff88e7c5c4bf8dc0e75fa93dfe0ddbea8a
|
data/lib/ldclient-rb/config.rb
CHANGED
@@ -13,6 +13,18 @@ module LaunchDarkly
|
|
13
13
|
#
|
14
14
|
# Constructor for creating custom LaunchDarkly configurations.
|
15
15
|
#
|
16
|
+
# `user_keys_capacity` and `user_keys_flush_interval` are deprecated
|
17
|
+
# configuration options. They exist to maintain backwards compatibility
|
18
|
+
# with previous configurations. Newer code should prefer their replacement
|
19
|
+
# options -- `context_keys_capacity` and `context_keys_flush_interval`.
|
20
|
+
#
|
21
|
+
# In the event both the user and context variations are provided, the
|
22
|
+
# context specific configuration option will take precedence.
|
23
|
+
#
|
24
|
+
# Similarly, `private_attribute_names` is deprecated. Newer code should
|
25
|
+
# prefer `private_attributes`. If both are provided, `private_attributes`
|
26
|
+
# will take precedence.
|
27
|
+
#
|
16
28
|
# @param opts [Hash] the configuration options
|
17
29
|
# @option opts [Logger] :logger See {#logger}.
|
18
30
|
# @option opts [String] :base_uri ("https://sdk.launchdarkly.com") See {#base_uri}.
|
@@ -31,19 +43,20 @@ module LaunchDarkly
|
|
31
43
|
# @option opts [Boolean] :stream (true) See {#stream?}.
|
32
44
|
# @option opts [Boolean] all_attributes_private (false) See {#all_attributes_private}.
|
33
45
|
# @option opts [Array] :private_attribute_names See {#private_attribute_names}.
|
46
|
+
# @option opts [Array] :private_attributes See {#private_attributes}.
|
34
47
|
# @option opts [Boolean] :send_events (true) See {#send_events}.
|
35
48
|
# @option opts [Integer] :user_keys_capacity (1000) See {#user_keys_capacity}.
|
49
|
+
# @option opts [Integer] :context_keys_capacity (1000) See {#context_keys_capacity}.
|
36
50
|
# @option opts [Float] :user_keys_flush_interval (300) See {#user_keys_flush_interval}.
|
37
|
-
# @option opts [
|
51
|
+
# @option opts [Float] :context_keys_flush_interval (300) See {#context_keys_flush_interval}.
|
38
52
|
# @option opts [Object] :data_source See {#data_source}.
|
39
|
-
# @option opts [Object] :update_processor Obsolete synonym for `data_source`.
|
40
|
-
# @option opts [Object] :update_processor_factory Obsolete synonym for `data_source`.
|
41
53
|
# @option opts [Boolean] :diagnostic_opt_out (false) See {#diagnostic_opt_out?}.
|
42
54
|
# @option opts [Float] :diagnostic_recording_interval (900) See {#diagnostic_recording_interval}.
|
43
55
|
# @option opts [String] :wrapper_name See {#wrapper_name}.
|
44
56
|
# @option opts [String] :wrapper_version See {#wrapper_version}.
|
45
57
|
# @option opts [#open] :socket_factory See {#socket_factory}.
|
46
58
|
# @option opts [BigSegmentsConfig] :big_segments See {#big_segments}.
|
59
|
+
# @option opts [Hash] :application See {#application}
|
47
60
|
#
|
48
61
|
def initialize(opts = {})
|
49
62
|
@base_uri = (opts[:base_uri] || Config.default_base_uri).chomp("/")
|
@@ -62,14 +75,11 @@ module LaunchDarkly
|
|
62
75
|
@offline = opts.has_key?(:offline) ? opts[:offline] : Config.default_offline
|
63
76
|
@poll_interval = opts.has_key?(:poll_interval) && opts[:poll_interval] > Config.default_poll_interval ? opts[:poll_interval] : Config.default_poll_interval
|
64
77
|
@all_attributes_private = opts[:all_attributes_private] || false
|
65
|
-
@
|
78
|
+
@private_attributes = opts[:private_attributes] || opts[:private_attribute_names] || []
|
66
79
|
@send_events = opts.has_key?(:send_events) ? opts[:send_events] : Config.default_send_events
|
67
|
-
@
|
68
|
-
@
|
69
|
-
@
|
70
|
-
@data_source = opts[:data_source] || opts[:update_processor] || opts[:update_processor_factory]
|
71
|
-
@update_processor = opts[:update_processor]
|
72
|
-
@update_processor_factory = opts[:update_processor_factory]
|
80
|
+
@context_keys_capacity = opts[:context_keys_capacity] || opts[:user_keys_capacity] || Config.default_context_keys_capacity
|
81
|
+
@context_keys_flush_interval = opts[:context_keys_flush_interval] || opts[:user_keys_flush_interval] || Config.default_user_keys_flush_interval
|
82
|
+
@data_source = opts[:data_source]
|
73
83
|
@diagnostic_opt_out = opts.has_key?(:diagnostic_opt_out) && opts[:diagnostic_opt_out]
|
74
84
|
@diagnostic_recording_interval = opts.has_key?(:diagnostic_recording_interval) && opts[:diagnostic_recording_interval] > Config.minimum_diagnostic_recording_interval ?
|
75
85
|
opts[:diagnostic_recording_interval] : Config.default_diagnostic_recording_interval
|
@@ -77,6 +87,7 @@ module LaunchDarkly
|
|
77
87
|
@wrapper_version = opts[:wrapper_version]
|
78
88
|
@socket_factory = opts[:socket_factory]
|
79
89
|
@big_segments = opts[:big_segments] || BigSegmentsConfig.new(store: nil)
|
90
|
+
@application = LaunchDarkly::Impl::Util.validate_application_info(opts[:application] || {}, @logger)
|
80
91
|
end
|
81
92
|
|
82
93
|
#
|
@@ -124,7 +135,7 @@ module LaunchDarkly
|
|
124
135
|
def use_ldd?
|
125
136
|
@use_ldd
|
126
137
|
end
|
127
|
-
|
138
|
+
|
128
139
|
#
|
129
140
|
# Whether the client should be initialized in offline mode. In offline mode, default values are
|
130
141
|
# returned for all flags and no remote network requests are made.
|
@@ -207,28 +218,37 @@ module LaunchDarkly
|
|
207
218
|
attr_reader :feature_store
|
208
219
|
|
209
220
|
#
|
210
|
-
# True if all
|
221
|
+
# True if all context attributes (other than the key) should be considered private. This means
|
211
222
|
# that the attribute values will not be sent to LaunchDarkly in analytics events and will not
|
212
223
|
# appear on the LaunchDarkly dashboard.
|
213
224
|
# @return [Boolean]
|
214
|
-
# @see #
|
225
|
+
# @see #private_attributes
|
215
226
|
#
|
216
227
|
attr_reader :all_attributes_private
|
217
228
|
|
218
229
|
#
|
219
|
-
# A list of
|
230
|
+
# A list of context attribute names that should always be considered private. This means that the
|
220
231
|
# attribute values will not be sent to LaunchDarkly in analytics events and will not appear on
|
221
232
|
# the LaunchDarkly dashboard.
|
222
233
|
#
|
223
|
-
# You can also specify the same behavior for an individual flag evaluation
|
224
|
-
#
|
225
|
-
#
|
234
|
+
# You can also specify the same behavior for an individual flag evaluation
|
235
|
+
# by providing the context object with a list of private attributes.
|
236
|
+
#
|
237
|
+
# @see https://docs.launchdarkly.com/sdk/features/user-context-config#using-private-attributes
|
226
238
|
#
|
227
239
|
# @return [Array<String>]
|
228
240
|
# @see #all_attributes_private
|
229
241
|
#
|
230
|
-
attr_reader :
|
231
|
-
|
242
|
+
attr_reader :private_attributes
|
243
|
+
|
244
|
+
#
|
245
|
+
# @deprecated Backwards compatibility alias for #private_attributes.
|
246
|
+
#
|
247
|
+
# @return [Integer]
|
248
|
+
# @see #private_attributes
|
249
|
+
#
|
250
|
+
alias :private_attribute_names :private_attributes
|
251
|
+
|
232
252
|
#
|
233
253
|
# Whether to send events back to LaunchDarkly. This differs from {#offline?} in that it affects
|
234
254
|
# only the sending of client-side events, not streaming or polling for events from the server.
|
@@ -237,27 +257,35 @@ module LaunchDarkly
|
|
237
257
|
attr_reader :send_events
|
238
258
|
|
239
259
|
#
|
240
|
-
# The number of
|
241
|
-
# amount of duplicate
|
260
|
+
# The number of context keys that the event processor can remember at any one time. This reduces the
|
261
|
+
# amount of duplicate context details sent in analytics events.
|
242
262
|
# @return [Integer]
|
243
|
-
# @see #
|
263
|
+
# @see #context_keys_flush_interval
|
244
264
|
#
|
245
|
-
attr_reader :
|
265
|
+
attr_reader :context_keys_capacity
|
246
266
|
|
247
267
|
#
|
248
|
-
#
|
268
|
+
# @deprecated Backwards compatibility alias for #context_keys_capacity.
|
269
|
+
#
|
270
|
+
# @return [Integer]
|
271
|
+
# @see #context_keys_flush_interval
|
272
|
+
#
|
273
|
+
alias :user_keys_capacity :context_keys_capacity
|
274
|
+
|
275
|
+
#
|
276
|
+
# The interval in seconds at which the event processor will reset its set of known context keys.
|
249
277
|
# @return [Float]
|
250
|
-
# @see #
|
278
|
+
# @see #context_keys_capacity
|
251
279
|
#
|
252
|
-
attr_reader :
|
280
|
+
attr_reader :context_keys_flush_interval
|
253
281
|
|
254
282
|
#
|
255
|
-
#
|
256
|
-
#
|
257
|
-
#
|
258
|
-
# @
|
283
|
+
# @deprecated Backwards compatibility alias for #context_keys_flush_interval.
|
284
|
+
#
|
285
|
+
# @return [Integer]
|
286
|
+
# @see #context_keys_flush_interval
|
259
287
|
#
|
260
|
-
|
288
|
+
alias :user_keys_flush_interval :context_keys_flush_interval
|
261
289
|
|
262
290
|
#
|
263
291
|
# An object that is responsible for receiving feature flag data from LaunchDarkly. By default,
|
@@ -277,18 +305,30 @@ module LaunchDarkly
|
|
277
305
|
#
|
278
306
|
# Configuration options related to Big Segments.
|
279
307
|
#
|
280
|
-
# Big Segments are a specific type of
|
308
|
+
# Big Segments are a specific type of segments. For more information, read the LaunchDarkly
|
281
309
|
# documentation: https://docs.launchdarkly.com/home/users/big-segments
|
282
310
|
#
|
283
311
|
# @return [BigSegmentsConfig]
|
284
312
|
#
|
285
313
|
attr_reader :big_segments
|
286
314
|
|
287
|
-
#
|
288
|
-
|
289
|
-
|
290
|
-
#
|
291
|
-
|
315
|
+
#
|
316
|
+
# An object that allows configuration of application metadata.
|
317
|
+
#
|
318
|
+
# Application metadata may be used in LaunchDarkly analytics or other product features, but does not affect feature flag evaluations.
|
319
|
+
#
|
320
|
+
# If you want to set non-default values for any of these fields, provide the appropriately configured hash to the {Config} object.
|
321
|
+
#
|
322
|
+
# @example Configuring application information
|
323
|
+
# opts[:application] = {
|
324
|
+
# id: "MY APPLICATION ID",
|
325
|
+
# version: "MY APPLICATION VERSION"
|
326
|
+
# }
|
327
|
+
# config = LDConfig.new(opts)
|
328
|
+
#
|
329
|
+
# @return [Hash]
|
330
|
+
#
|
331
|
+
attr_reader :application
|
292
332
|
|
293
333
|
#
|
294
334
|
# Set to true to opt out of sending diagnostics data.
|
@@ -426,8 +466,8 @@ module LaunchDarkly
|
|
426
466
|
#
|
427
467
|
def self.default_logger
|
428
468
|
if defined?(Rails) && Rails.respond_to?(:logger)
|
429
|
-
Rails.logger
|
430
|
-
else
|
469
|
+
Rails.logger
|
470
|
+
else
|
431
471
|
log = ::Logger.new($stdout)
|
432
472
|
log.level = ::Logger::WARN
|
433
473
|
log
|
@@ -483,21 +523,33 @@ module LaunchDarkly
|
|
483
523
|
end
|
484
524
|
|
485
525
|
#
|
486
|
-
# The default value for {#
|
526
|
+
# The default value for {#context_keys_capacity}.
|
487
527
|
# @return [Integer] 1000
|
488
528
|
#
|
489
|
-
def self.
|
529
|
+
def self.default_context_keys_capacity
|
490
530
|
1000
|
491
531
|
end
|
492
532
|
|
493
533
|
#
|
494
|
-
# The default value for {#
|
534
|
+
# The default value for {#context_keys_flush_interval}.
|
495
535
|
# @return [Float] 300
|
496
536
|
#
|
497
|
-
def self.
|
537
|
+
def self.default_context_keys_flush_interval
|
498
538
|
300
|
499
539
|
end
|
500
540
|
|
541
|
+
class << self
|
542
|
+
#
|
543
|
+
# @deprecated Backwards compatibility alias for #default_context_keys_capacity
|
544
|
+
#
|
545
|
+
alias :default_user_keys_capacity :default_context_keys_capacity
|
546
|
+
|
547
|
+
#
|
548
|
+
# @deprecated Backwards compatibility alias for #default_context_keys_flush_interval
|
549
|
+
#
|
550
|
+
alias :default_user_keys_flush_interval :default_context_keys_flush_interval
|
551
|
+
end
|
552
|
+
|
501
553
|
#
|
502
554
|
# The default value for {#diagnostic_recording_interval}.
|
503
555
|
# @return [Float] 900
|
@@ -518,7 +570,7 @@ module LaunchDarkly
|
|
518
570
|
#
|
519
571
|
# Configuration options related to Big Segments.
|
520
572
|
#
|
521
|
-
# Big Segments are a specific type of
|
573
|
+
# Big Segments are a specific type of segments. For more information, read the LaunchDarkly
|
522
574
|
# documentation: https://docs.launchdarkly.com/home/users/big-segments
|
523
575
|
#
|
524
576
|
# If your application uses Big Segments, you will need to create a `BigSegmentsConfig` that at a
|
@@ -532,8 +584,8 @@ module LaunchDarkly
|
|
532
584
|
# client = LaunchDarkly::LDClient.new(my_sdk_key, config)
|
533
585
|
#
|
534
586
|
class BigSegmentsConfig
|
535
|
-
|
536
|
-
|
587
|
+
DEFAULT_CONTEXT_CACHE_SIZE = 1000
|
588
|
+
DEFAULT_CONTEXT_CACHE_TIME = 5
|
537
589
|
DEFAULT_STATUS_POLL_INTERVAL = 5
|
538
590
|
DEFAULT_STALE_AFTER = 2 * 60
|
539
591
|
|
@@ -541,15 +593,15 @@ module LaunchDarkly
|
|
541
593
|
# Constructor for setting Big Segments options.
|
542
594
|
#
|
543
595
|
# @param store [LaunchDarkly::Interfaces::BigSegmentStore] the data store implementation
|
544
|
-
# @param
|
545
|
-
# @param
|
596
|
+
# @param context_cache_size [Integer] See {#context_cache_size}.
|
597
|
+
# @param context_cache_time [Float] See {#context_cache_time}.
|
546
598
|
# @param status_poll_interval [Float] See {#status_poll_interval}.
|
547
599
|
# @param stale_after [Float] See {#stale_after}.
|
548
600
|
#
|
549
|
-
def initialize(store:,
|
601
|
+
def initialize(store:, context_cache_size: nil, context_cache_time: nil, status_poll_interval: nil, stale_after: nil)
|
550
602
|
@store = store
|
551
|
-
@
|
552
|
-
@
|
603
|
+
@context_cache_size = context_cache_size.nil? ? DEFAULT_CONTEXT_CACHE_SIZE : context_cache_size
|
604
|
+
@context_cache_time = context_cache_time.nil? ? DEFAULT_CONTEXT_CACHE_TIME : context_cache_time
|
553
605
|
@status_poll_interval = status_poll_interval.nil? ? DEFAULT_STATUS_POLL_INTERVAL : status_poll_interval
|
554
606
|
@stale_after = stale_after.nil? ? DEFAULT_STALE_AFTER : stale_after
|
555
607
|
end
|
@@ -559,14 +611,28 @@ module LaunchDarkly
|
|
559
611
|
# @return [LaunchDarkly::Interfaces::BigSegmentStore]
|
560
612
|
attr_reader :store
|
561
613
|
|
562
|
-
# The maximum number of
|
614
|
+
# The maximum number of contexts whose Big Segment state will be cached by the SDK at any given time.
|
563
615
|
# @return [Integer]
|
564
|
-
attr_reader :
|
616
|
+
attr_reader :context_cache_size
|
565
617
|
|
566
|
-
#
|
618
|
+
#
|
619
|
+
# @deprecated Backwards compatibility alias for #context_cache_size
|
620
|
+
#
|
621
|
+
# @return [Integer]
|
622
|
+
#
|
623
|
+
alias :user_cache_size :context_cache_size
|
624
|
+
|
625
|
+
# The maximum length of time (in seconds) that the Big Segment state for a context will be cached
|
567
626
|
# by the SDK.
|
568
627
|
# @return [Float]
|
569
|
-
attr_reader :
|
628
|
+
attr_reader :context_cache_time
|
629
|
+
|
630
|
+
#
|
631
|
+
# @deprecated Backwards compatibility alias for #context_cache_time
|
632
|
+
#
|
633
|
+
# @return [Float]
|
634
|
+
#
|
635
|
+
alias :user_cache_time :context_cache_time
|
570
636
|
|
571
637
|
# The interval (in seconds) at which the SDK will poll the Big Segment store to make sure it is
|
572
638
|
# available and to determine how long ago it was updated.
|