@@ -34,12 +34,23 @@ class Config
3434 # @option opts [Object] :cache_store A cache store for the Faraday HTTP caching
3535 # library. Defaults to the Rails cache in a Rails environment, or a
3636 # thread-safe in-memory store otherwise.
37+ # @option opts [Boolean] :use_ldd (false) Whether you are using the LaunchDarkly relay proxy in
38+ # daemon mode. In this configuration, the client will not use a streaming connection to listen
39+ # for updates, but instead will get feature state from a Redis instance. The `stream` and
40+ # `poll_interval` options will be ignored if this option is set to true.
3741 # @option opts [Boolean] :offline (false) Whether the client should be initialized in
3842 # offline mode. In offline mode, default values are returned for all flags and no
3943 # remote network requests are made.
4044 # @option opts [Float] :poll_interval (1) The number of seconds between polls for flag updates
4145 # if streaming is off.
4246 # @option opts [Boolean] :stream (true) Whether or not the streaming API should be used to receive flag updates.
47+ # @option opts [Boolean] all_attributes_private (false) If true, all user attributes (other than the key)
48+ # will be private, not just the attributes specified in `private_attribute_names`.
49+ # @option opts [Array] :private_attribute_names Marks a set of attribute names private. Any users sent to
50+ # LaunchDarkly with this configuration active will have attributes with these names removed.
51+ # @option opts [Boolean] :send_events (true) Whether or not to send events back to LaunchDarkly.
52+ # This differs from `offline` in that it affects only the sending of client-side events, not
53+ # streaming or polling for events from the server.
4354 #
4455 # @return [type] [description]
4556 # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
@@ -55,9 +66,13 @@ def initialize(opts = {})
5566 @read_timeout = opts [ :read_timeout ] || Config . default_read_timeout
5667 @feature_store = opts [ :feature_store ] || Config . default_feature_store
5768 @stream = opts . has_key? ( :stream ) ? opts [ :stream ] : Config . default_stream
69+ @use_ldd = opts . has_key? ( :use_ldd ) ? opts [ :use_ldd ] : Config . default_use_ldd
5870 @offline = opts . has_key? ( :offline ) ? opts [ :offline ] : Config . default_offline
5971 @poll_interval = opts . has_key? ( :poll_interval ) && opts [ :poll_interval ] > 1 ? opts [ :poll_interval ] : Config . default_poll_interval
6072 @proxy = opts [ :proxy ] || Config . default_proxy
73+ @all_attributes_private = opts [ :all_attributes_private ] || false
74+ @private_attribute_names = opts [ :private_attribute_names ] || [ ]
75+ @send_events = opts . has_key? ( :send_events ) ? opts [ :send_events ] : Config . default_send_events
6176 end
6277
6378 #
@@ -87,6 +102,16 @@ def stream?
87102 @stream
88103 end
89104
105+ #
106+ # Whether to use the LaunchDarkly relay proxy in daemon mode. In this mode, we do
107+ # not use polling or streaming to get feature flag updates from the server, but instead
108+ # read them from a Redis instance that is updated by the proxy.
109+ #
110+ # @return [Boolean] True if using the LaunchDarkly relay proxy in daemon mode
111+ def use_ldd?
112+ @use_ldd
113+ end
114+
90115 # TODO docs
91116 def offline?
92117 @offline
@@ -150,6 +175,15 @@ def offline?
150175 #
151176 attr_reader :proxy
152177
178+ attr_reader :all_attributes_private
179+
180+ attr_reader :private_attribute_names
181+
182+ #
183+ # Whether to send events back to LaunchDarkly.
184+ #
185+ attr_reader :send_events
186+
153187 #
154188 # The default LaunchDarkly client configuration. This configuration sets
155189 # reasonable defaults for most users.
@@ -209,6 +243,10 @@ def self.default_stream
209243 true
210244 end
211245
246+ def self . default_use_ldd
247+ false
248+ end
249+
212250 def self . default_feature_store
213251 InMemoryFeatureStore . new
214252 end
@@ -220,5 +258,9 @@ def self.default_offline
220258 def self . default_poll_interval
221259 1
222260 end
261+
262+ def self . default_send_events
263+ true
264+ end
223265 end
224266end
0 commit comments