Class: LaunchDarkly::Config
- Inherits:
-
Object
- Object
- LaunchDarkly::Config
- Defined in:
- lib/ldclient-rb/config.rb
Overview
This class exposes advanced configuration options for the LaunchDarkly client library. Most users will not need to use a custom configuration– the default configuration sets sane defaults for most use cases.
Instance Attribute Summary collapse
-
#all_attributes_private ⇒ Object
readonly
Returns the value of attribute all_attributes_private.
-
#base_uri ⇒ String
readonly
The base URL for the LaunchDarkly server.
-
#cache_store ⇒ Object
readonly
The store for the Faraday HTTP caching library.
-
#capacity ⇒ Integer
readonly
The capacity of the events buffer.
-
#connect_timeout ⇒ Float
readonly
The connect timeout for network connections in seconds.
-
#events_uri ⇒ String
readonly
The base URL for the LaunchDarkly events server.
-
#feature_store ⇒ Object
readonly
A store for feature flag configuration rules.
-
#flush_interval ⇒ Float
readonly
The number of seconds between flushes of the event buffer.
-
#inline_users_in_events ⇒ Object
readonly
Whether to include full user details in every analytics event.
-
#logger ⇒ Logger
readonly
The configured logger for the LaunchDarkly client.
-
#poll_interval ⇒ Object
readonly
The number of seconds to wait before polling for feature flag updates.
-
#private_attribute_names ⇒ Object
readonly
Returns the value of attribute private_attribute_names.
-
#proxy ⇒ Object
readonly
The proxy configuration string.
-
#read_timeout ⇒ Float
readonly
The read timeout for network connections in seconds.
-
#send_events ⇒ Object
readonly
Whether to send events back to LaunchDarkly.
-
#stream_uri ⇒ String
readonly
The base URL for the LaunchDarkly streaming server.
-
#update_processor ⇒ Object
readonly
Returns the value of attribute update_processor.
-
#update_processor_factory ⇒ Object
readonly
Returns the value of attribute update_processor_factory.
-
#user_keys_capacity ⇒ Object
readonly
The number of user keys that the event processor can remember at any one time, so that duplicate user details will not be sent in analytics events.
-
#user_keys_flush_interval ⇒ Object
readonly
The interval in seconds at which the event processor will reset its set of known user keys.
Class Method Summary collapse
-
.default ⇒ Config
The default LaunchDarkly client configuration.
- .default_base_uri ⇒ Object
- .default_cache_store ⇒ Object
- .default_capacity ⇒ Object
- .default_connect_timeout ⇒ Object
- .default_events_uri ⇒ Object
- .default_feature_store ⇒ Object
- .default_flush_interval ⇒ Object
- .default_logger ⇒ Object
- .default_offline ⇒ Object
- .default_poll_interval ⇒ Object
- .default_proxy ⇒ Object
- .default_read_timeout ⇒ Object
- .default_send_events ⇒ Object
- .default_stream ⇒ Object
- .default_stream_uri ⇒ Object
- .default_use_ldd ⇒ Object
- .default_user_keys_capacity ⇒ Object
- .default_user_keys_flush_interval ⇒ Object
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ type
constructor
Constructor for creating custom LaunchDarkly configurations.
-
#offline? ⇒ Boolean
TODO docs.
-
#stream? ⇒ Boolean
Whether streaming mode should be enabled.
-
#use_ldd? ⇒ Boolean
Whether to use the LaunchDarkly relay proxy in daemon mode.
Constructor Details
#initialize(opts = {}) ⇒ type
Constructor for creating custom LaunchDarkly configurations.
rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/ldclient-rb/config.rb', line 71 def initialize(opts = {}) @base_uri = (opts[:base_uri] || Config.default_base_uri).chomp("/") @stream_uri = (opts[:stream_uri] || Config.default_stream_uri).chomp("/") @events_uri = (opts[:events_uri] || Config.default_events_uri).chomp("/") @capacity = opts[:capacity] || Config.default_capacity @logger = opts[:logger] || Config.default_logger @cache_store = opts[:cache_store] || Config.default_cache_store @flush_interval = opts[:flush_interval] || Config.default_flush_interval @connect_timeout = opts[:connect_timeout] || Config.default_connect_timeout @read_timeout = opts[:read_timeout] || Config.default_read_timeout @feature_store = opts[:feature_store] || Config.default_feature_store @stream = opts.has_key?(:stream) ? opts[:stream] : Config.default_stream @use_ldd = opts.has_key?(:use_ldd) ? opts[:use_ldd] : Config.default_use_ldd @offline = opts.has_key?(:offline) ? opts[:offline] : Config.default_offline @poll_interval = opts.has_key?(:poll_interval) && opts[:poll_interval] > Config.default_poll_interval ? opts[:poll_interval] : Config.default_poll_interval @proxy = opts[:proxy] || Config.default_proxy @all_attributes_private = opts[:all_attributes_private] || false @private_attribute_names = opts[:private_attribute_names] || [] @send_events = opts.has_key?(:send_events) ? opts[:send_events] : Config.default_send_events @user_keys_capacity = opts[:user_keys_capacity] || Config.default_user_keys_capacity @user_keys_flush_interval = opts[:user_keys_flush_interval] || Config.default_user_keys_flush_interval @inline_users_in_events = opts[:inline_users_in_events] || false @update_processor = opts[:update_processor] @update_processor_factory = opts[:update_processor_factory] end |
Instance Attribute Details
#all_attributes_private ⇒ Object (readonly)
Returns the value of attribute all_attributes_private.
196 197 198 |
# File 'lib/ldclient-rb/config.rb', line 196 def all_attributes_private @all_attributes_private end |
#base_uri ⇒ String (readonly)
The base URL for the LaunchDarkly server.
101 102 103 |
# File 'lib/ldclient-rb/config.rb', line 101 def base_uri @base_uri end |
#cache_store ⇒ Object (readonly)
The store for the Faraday HTTP caching library. Stores should respond to ‘read’ and ‘write’ requests.
173 174 175 |
# File 'lib/ldclient-rb/config.rb', line 173 def cache_store @cache_store end |
#capacity ⇒ Integer (readonly)
The capacity of the events buffer. The client buffers up to this many events in memory before flushing. If the capacity is exceeded before the buffer is flushed, events will be discarded. Increasing the capacity means that events are less likely to be discarded, at the cost of consuming more memory.
166 167 168 |
# File 'lib/ldclient-rb/config.rb', line 166 def capacity @capacity end |
#connect_timeout ⇒ Float (readonly)
The connect timeout for network connections in seconds.
185 186 187 |
# File 'lib/ldclient-rb/config.rb', line 185 def connect_timeout @connect_timeout end |
#events_uri ⇒ String (readonly)
The base URL for the LaunchDarkly events server.
113 114 115 |
# File 'lib/ldclient-rb/config.rb', line 113 def events_uri @events_uri end |
#feature_store ⇒ Object (readonly)
A store for feature flag configuration rules.
190 191 192 |
# File 'lib/ldclient-rb/config.rb', line 190 def feature_store @feature_store end |
#flush_interval ⇒ Float (readonly)
The number of seconds between flushes of the event buffer. Decreasing the flush interval means that the event buffer is less likely to reach capacity.
144 145 146 |
# File 'lib/ldclient-rb/config.rb', line 144 def flush_interval @flush_interval end |
#inline_users_in_events ⇒ Object (readonly)
Whether to include full user details in every analytics event. By default, events will only include the user key, except for one “index” event that provides the full details for the user.
221 222 223 |
# File 'lib/ldclient-rb/config.rb', line 221 def inline_users_in_events @inline_users_in_events end |
#logger ⇒ Logger (readonly)
The configured logger for the LaunchDarkly client. The client library uses the log to print warning and error messages.
156 157 158 |
# File 'lib/ldclient-rb/config.rb', line 156 def logger @logger end |
#poll_interval ⇒ Object (readonly)
The number of seconds to wait before polling for feature flag updates. This option has no effect unless streaming is disabled
149 150 151 |
# File 'lib/ldclient-rb/config.rb', line 149 def poll_interval @poll_interval end |
#private_attribute_names ⇒ Object (readonly)
Returns the value of attribute private_attribute_names.
198 199 200 |
# File 'lib/ldclient-rb/config.rb', line 198 def private_attribute_names @private_attribute_names end |
#proxy ⇒ Object (readonly)
The proxy configuration string
194 195 196 |
# File 'lib/ldclient-rb/config.rb', line 194 def proxy @proxy end |
#read_timeout ⇒ Float (readonly)
The read timeout for network connections in seconds.
179 180 181 |
# File 'lib/ldclient-rb/config.rb', line 179 def read_timeout @read_timeout end |
#send_events ⇒ Object (readonly)
Whether to send events back to LaunchDarkly.
203 204 205 |
# File 'lib/ldclient-rb/config.rb', line 203 def send_events @send_events end |
#stream_uri ⇒ String (readonly)
The base URL for the LaunchDarkly streaming server.
107 108 109 |
# File 'lib/ldclient-rb/config.rb', line 107 def stream_uri @stream_uri end |
#update_processor ⇒ Object (readonly)
Returns the value of attribute update_processor.
223 224 225 |
# File 'lib/ldclient-rb/config.rb', line 223 def update_processor @update_processor end |
#update_processor_factory ⇒ Object (readonly)
Returns the value of attribute update_processor_factory.
225 226 227 |
# File 'lib/ldclient-rb/config.rb', line 225 def update_processor_factory @update_processor_factory end |
#user_keys_capacity ⇒ Object (readonly)
The number of user keys that the event processor can remember at any one time, so that duplicate user details will not be sent in analytics events.
209 210 211 |
# File 'lib/ldclient-rb/config.rb', line 209 def user_keys_capacity @user_keys_capacity end |
#user_keys_flush_interval ⇒ Object (readonly)
The interval in seconds at which the event processor will reset its set of known user keys.
214 215 216 |
# File 'lib/ldclient-rb/config.rb', line 214 def user_keys_flush_interval @user_keys_flush_interval end |
Class Method Details
.default ⇒ Config
The default LaunchDarkly client configuration. This configuration sets reasonable defaults for most users.
232 233 234 |
# File 'lib/ldclient-rb/config.rb', line 232 def self.default Config.new end |
.default_base_uri ⇒ Object
240 241 242 |
# File 'lib/ldclient-rb/config.rb', line 240 def self.default_base_uri "https://app.launchdarkly.com" end |
.default_cache_store ⇒ Object
252 253 254 |
# File 'lib/ldclient-rb/config.rb', line 252 def self.default_cache_store defined?(Rails) && Rails.respond_to?(:cache) ? Rails.cache : ThreadSafeMemoryStore.new end |
.default_capacity ⇒ Object
236 237 238 |
# File 'lib/ldclient-rb/config.rb', line 236 def self.default_capacity 10000 end |
.default_connect_timeout ⇒ Object
264 265 266 |
# File 'lib/ldclient-rb/config.rb', line 264 def self.default_connect_timeout 2 end |
.default_events_uri ⇒ Object
248 249 250 |
# File 'lib/ldclient-rb/config.rb', line 248 def self.default_events_uri "https://events.launchdarkly.com" end |
.default_feature_store ⇒ Object
290 291 292 |
# File 'lib/ldclient-rb/config.rb', line 290 def self.default_feature_store InMemoryFeatureStore.new end |
.default_flush_interval ⇒ Object
256 257 258 |
# File 'lib/ldclient-rb/config.rb', line 256 def self.default_flush_interval 10 end |
.default_logger ⇒ Object
272 273 274 275 276 277 278 279 280 |
# File 'lib/ldclient-rb/config.rb', line 272 def self.default_logger if defined?(Rails) && Rails.respond_to?(:logger) Rails.logger else log = ::Logger.new($stdout) log.level = ::Logger::WARN log end end |
.default_offline ⇒ Object
294 295 296 |
# File 'lib/ldclient-rb/config.rb', line 294 def self.default_offline false end |
.default_poll_interval ⇒ Object
298 299 300 |
# File 'lib/ldclient-rb/config.rb', line 298 def self.default_poll_interval 30 end |
.default_proxy ⇒ Object
268 269 270 |
# File 'lib/ldclient-rb/config.rb', line 268 def self.default_proxy nil end |
.default_read_timeout ⇒ Object
260 261 262 |
# File 'lib/ldclient-rb/config.rb', line 260 def self.default_read_timeout 10 end |
.default_send_events ⇒ Object
302 303 304 |
# File 'lib/ldclient-rb/config.rb', line 302 def self.default_send_events true end |
.default_stream ⇒ Object
282 283 284 |
# File 'lib/ldclient-rb/config.rb', line 282 def self.default_stream true end |
.default_stream_uri ⇒ Object
244 245 246 |
# File 'lib/ldclient-rb/config.rb', line 244 def self.default_stream_uri "https://stream.launchdarkly.com" end |
.default_use_ldd ⇒ Object
286 287 288 |
# File 'lib/ldclient-rb/config.rb', line 286 def self.default_use_ldd false end |
.default_user_keys_capacity ⇒ Object
306 307 308 |
# File 'lib/ldclient-rb/config.rb', line 306 def self.default_user_keys_capacity 1000 end |
.default_user_keys_flush_interval ⇒ Object
310 311 312 |
# File 'lib/ldclient-rb/config.rb', line 310 def self.default_user_keys_flush_interval 300 end |
Instance Method Details
#offline? ⇒ Boolean
TODO docs
135 136 137 |
# File 'lib/ldclient-rb/config.rb', line 135 def offline? @offline end |
#stream? ⇒ Boolean
Whether streaming mode should be enabled. Streaming mode asynchronously updates feature flags in real-time using server-sent events.
120 121 122 |
# File 'lib/ldclient-rb/config.rb', line 120 def stream? @stream end |
#use_ldd? ⇒ Boolean
Whether to use the LaunchDarkly relay proxy in daemon mode. In this mode, we do not use polling or streaming to get feature flag updates from the server, but instead read them from a Redis instance that is updated by the proxy.
130 131 132 |
# File 'lib/ldclient-rb/config.rb', line 130 def use_ldd? @use_ldd end |