@@ -34,12 +34,23 @@ class Config
34
34
# @option opts [Object] :cache_store A cache store for the Faraday HTTP caching
35
35
# library. Defaults to the Rails cache in a Rails environment, or a
36
36
# 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.
37
41
# @option opts [Boolean] :offline (false) Whether the client should be initialized in
38
42
# offline mode. In offline mode, default values are returned for all flags and no
39
43
# remote network requests are made.
40
44
# @option opts [Float] :poll_interval (1) The number of seconds between polls for flag updates
41
45
# if streaming is off.
42
46
# @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.
43
54
#
44
55
# @return [type] [description]
45
56
# rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
@@ -55,9 +66,13 @@ def initialize(opts = {})
55
66
@read_timeout = opts [ :read_timeout ] || Config . default_read_timeout
56
67
@feature_store = opts [ :feature_store ] || Config . default_feature_store
57
68
@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
58
70
@offline = opts . has_key? ( :offline ) ? opts [ :offline ] : Config . default_offline
59
71
@poll_interval = opts . has_key? ( :poll_interval ) && opts [ :poll_interval ] > 1 ? opts [ :poll_interval ] : Config . default_poll_interval
60
72
@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
61
76
end
62
77
63
78
#
@@ -87,6 +102,16 @@ def stream?
87
102
@stream
88
103
end
89
104
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
+
90
115
# TODO docs
91
116
def offline?
92
117
@offline
@@ -150,6 +175,15 @@ def offline?
150
175
#
151
176
attr_reader :proxy
152
177
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
+
153
187
#
154
188
# The default LaunchDarkly client configuration. This configuration sets
155
189
# reasonable defaults for most users.
@@ -209,6 +243,10 @@ def self.default_stream
209
243
true
210
244
end
211
245
246
+ def self . default_use_ldd
247
+ false
248
+ end
249
+
212
250
def self . default_feature_store
213
251
InMemoryFeatureStore . new
214
252
end
@@ -220,5 +258,9 @@ def self.default_offline
220
258
def self . default_poll_interval
221
259
1
222
260
end
261
+
262
+ def self . default_send_events
263
+ true
264
+ end
223
265
end
224
266
end
0 commit comments