launchdarkly-server-sdk 8.9.0 → 8.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71cc03d71aa917c1f2ac00b689bddfe0efddb535d3e7c2cd227ef0796f1a77bb
4
- data.tar.gz: 37380c38265a220fdf591a34671492e5a3fb9825f29959b3b46ed0b435a43654
3
+ metadata.gz: a7101bb1e494892e6f290ea8293e1daa88cc9b1652714b1e784f7f65e68168a4
4
+ data.tar.gz: 5420c9a6aa5b7492a84a583fe362d02919f61422b3d5d859db44d86496fbbc3d
5
5
  SHA512:
6
- metadata.gz: 7e0263a677a3d559e9138384a2fcc7eee7651a59c59792104b17e7f9b34b4f169f9a77e71dd91cc03e23d48ce321bc1a8d60379f18a07b96f7c0550bdcfb5c6c
7
- data.tar.gz: 9fc01d2f4972879bb3ac598f59a82e3c0d4409d70fe32b2768eaa6acf554380311819244f435a2207eef34ba039bb49af5ab886967b93273827627613528d823
6
+ metadata.gz: 004c17af7aea8861d1de40dac99ae89e7ca8be8d21d99605e36c6225cc1e7b419948f30542ab500ca410b616331ede1c8acea165c324bd05db7086e344dd0cb8
7
+ data.tar.gz: e5433a32db3b0458b369d75adaf18978dd8dee3aa0252de12287aab1a54c4b71c3756003b9c73b3081c12fec07230fdd1406ba76f0acb7f125c87931d244cb6b
@@ -81,6 +81,7 @@ module LaunchDarkly
81
81
  @hooks = (opts[:hooks] || []).keep_if { |hook| hook.is_a? Interfaces::Hooks::Hook }
82
82
  @omit_anonymous_contexts = opts.has_key?(:omit_anonymous_contexts) && opts[:omit_anonymous_contexts]
83
83
  @data_source_update_sink = nil
84
+ @instance_id = nil
84
85
  end
85
86
 
86
87
  #
@@ -97,6 +98,18 @@ module LaunchDarkly
97
98
  #
98
99
  attr_accessor :data_source_update_sink
99
100
 
101
+
102
+ #
103
+ # Returns the unique identifier for this instance of the SDK.
104
+ #
105
+ # This property should only be set by the SDK. Long term access of this
106
+ # property is not supported; it is temporarily being exposed to maintain
107
+ # backwards compatibility while the SDK structure is updated.
108
+ #
109
+ # @private
110
+ #
111
+ attr_accessor :instance_id
112
+
100
113
  #
101
114
  # The base URL for the LaunchDarkly server. This is configurable mainly for testing
102
115
  # purposes; most users should use the default value.
@@ -10,6 +10,7 @@ module LaunchDarkly
10
10
  class ConsulFeatureStoreCore
11
11
  begin
12
12
  require "diplomat"
13
+ require "ostruct"
13
14
  CONSUL_ENABLED = true
14
15
  rescue ScriptError, StandardError
15
16
  CONSUL_ENABLED = false
@@ -11,6 +11,9 @@ module LaunchDarkly
11
11
 
12
12
  def self.default_http_headers(sdk_key, config)
13
13
  ret = { "Authorization" => sdk_key, "User-Agent" => "RubyClient/" + LaunchDarkly::VERSION }
14
+
15
+ ret["X-LaunchDarkly-Instance-Id"] = config.instance_id unless config.instance_id.nil?
16
+
14
17
  if config.wrapper_name
15
18
  ret["X-LaunchDarkly-Wrapper"] = config.wrapper_name +
16
19
  (config.wrapper_version ? "/" + config.wrapper_version : "")
@@ -13,6 +13,7 @@ require "concurrent/atomics"
13
13
  require "digest/sha1"
14
14
  require "forwardable"
15
15
  require "logger"
16
+ require "securerandom"
16
17
  require "benchmark"
17
18
  require "json"
18
19
  require "openssl"
@@ -56,25 +57,57 @@ module LaunchDarkly
56
57
  end
57
58
 
58
59
  @sdk_key = sdk_key
59
- @hooks = Concurrent::Array.new(config.hooks)
60
+ config.instance_id = SecureRandom.uuid
61
+ @config = config
62
+
63
+ start_up(wait_for_sec)
64
+ end
65
+
66
+ #
67
+ # Re-initializes an existing client after a process fork.
68
+ #
69
+ # The SDK relies on multiple background threads to operate correctly. When a process forks, `these threads are not
70
+ # available to the child <https://apidock.com/ruby/Process/fork/class>`.
71
+ #
72
+ # As a result, the SDK will not function correctly in the child process until it is re-initialized.
73
+ #
74
+ # This method is effectively equivalent to instantiating a new client. Future iterations of the SDK will provide
75
+ # increasingly efficient re-initializing improvements.
76
+ #
77
+ # Note that any configuration provided to the SDK will need to survive the forking process independently. For this
78
+ # reason, it is recommended that any listener or hook integrations be added postfork unless you are certain it can
79
+ # survive the forking process.
80
+ #
81
+ # @param wait_for_sec [Float] maximum time (in seconds) to wait for initialization
82
+ #
83
+ def postfork(wait_for_sec = 5)
84
+ @data_source = nil
85
+ @event_processor = nil
86
+ @big_segment_store_manager = nil
87
+
88
+ start_up(wait_for_sec)
89
+ end
90
+
91
+ private def start_up(wait_for_sec)
92
+ @hooks = Concurrent::Array.new(@config.hooks)
60
93
 
61
94
  @shared_executor = Concurrent::SingleThreadExecutor.new
62
95
 
63
- data_store_broadcaster = LaunchDarkly::Impl::Broadcaster.new(@shared_executor, config.logger)
96
+ data_store_broadcaster = LaunchDarkly::Impl::Broadcaster.new(@shared_executor, @config.logger)
64
97
  store_sink = LaunchDarkly::Impl::DataStore::UpdateSink.new(data_store_broadcaster)
65
98
 
66
99
  # We need to wrap the feature store object with a FeatureStoreClientWrapper in order to add
67
100
  # some necessary logic around updates. Unfortunately, we have code elsewhere that accesses
68
101
  # the feature store through the Config object, so we need to make a new Config that uses
69
102
  # the wrapped store.
70
- @store = Impl::FeatureStoreClientWrapper.new(config.feature_store, store_sink, config.logger)
71
- updated_config = config.clone
103
+ @store = Impl::FeatureStoreClientWrapper.new(@config.feature_store, store_sink, @config.logger)
104
+ updated_config = @config.clone
72
105
  updated_config.instance_variable_set(:@feature_store, @store)
73
106
  @config = updated_config
74
107
 
75
108
  @data_store_status_provider = LaunchDarkly::Impl::DataStore::StatusProvider.new(@store, store_sink)
76
109
 
77
- @big_segment_store_manager = Impl::BigSegmentStoreManager.new(config.big_segments, @config.logger)
110
+ @big_segment_store_manager = Impl::BigSegmentStoreManager.new(@config.big_segments, @config.logger)
78
111
  @big_segment_store_status_provider = @big_segment_store_manager.status_provider
79
112
 
80
113
  get_flag = lambda { |key| @store.get(FEATURES, key) }
@@ -83,7 +116,7 @@ module LaunchDarkly
83
116
  @evaluator = LaunchDarkly::Impl::Evaluator.new(get_flag, get_segment, get_big_segments_membership, @config.logger)
84
117
 
85
118
  if !@config.offline? && @config.send_events && !@config.diagnostic_opt_out?
86
- diagnostic_accumulator = Impl::DiagnosticAccumulator.new(Impl::DiagnosticAccumulator.create_diagnostic_id(sdk_key))
119
+ diagnostic_accumulator = Impl::DiagnosticAccumulator.new(Impl::DiagnosticAccumulator.create_diagnostic_id(@sdk_key))
87
120
  else
88
121
  diagnostic_accumulator = nil
89
122
  end
@@ -91,7 +124,7 @@ module LaunchDarkly
91
124
  if @config.offline? || !@config.send_events
92
125
  @event_processor = NullEventProcessor.new
93
126
  else
94
- @event_processor = EventProcessor.new(sdk_key, config, nil, diagnostic_accumulator)
127
+ @event_processor = EventProcessor.new(@sdk_key, @config, nil, diagnostic_accumulator)
95
128
  end
96
129
 
97
130
  if @config.use_ldd?
@@ -115,9 +148,9 @@ module LaunchDarkly
115
148
  # Currently, data source factories take two parameters unless they need to be aware of diagnostic_accumulator, in
116
149
  # which case they take three parameters. This will be changed in the future to use a less awkware mechanism.
117
150
  if data_source_or_factory.arity == 3
118
- @data_source = data_source_or_factory.call(sdk_key, @config, diagnostic_accumulator)
151
+ @data_source = data_source_or_factory.call(@sdk_key, @config, diagnostic_accumulator)
119
152
  else
120
- @data_source = data_source_or_factory.call(sdk_key, @config)
153
+ @data_source = data_source_or_factory.call(@sdk_key, @config)
121
154
  end
122
155
  else
123
156
  @data_source = data_source_or_factory
@@ -1,3 +1,3 @@
1
1
  module LaunchDarkly
2
- VERSION = "8.9.0" # x-release-please-version
2
+ VERSION = "8.10.0" # x-release-please-version
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: launchdarkly-server-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.9.0
4
+ version: 8.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - LaunchDarkly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-13 00:00:00.000000000 Z
11
+ date: 2025-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-dynamodb