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.
Class Method Summary collapse
-
.default ⇒ Config
The default LaunchDarkly client configuration.
- .default_base_uri ⇒ Object
- .default_capacity ⇒ Object
- .default_connect_timeout ⇒ Object
- .default_debug_stream ⇒ Object
- .default_feature_store ⇒ Object
- .default_flush_interval ⇒ Object
- .default_log_timings ⇒ Object
- .default_logger ⇒ Object
- .default_read_timeout ⇒ Object
- .default_store ⇒ Object
- .default_stream ⇒ Object
- .default_stream_uri ⇒ Object
Instance Method Summary collapse
-
#base_uri ⇒ String
The base URL for the LaunchDarkly server.
-
#capacity ⇒ Integer
The capacity of the events buffer.
-
#connect_timeout ⇒ Float
The connect timeout for network connections in seconds.
-
#debug_stream? ⇒ Boolean
Whether we should debug streaming mode.
-
#feature_store ⇒ Object
TODO docs.
-
#flush_interval ⇒ Float
The number of seconds between flushes of the event buffer.
-
#initialize(opts = {}) ⇒ type
constructor
Constructor for creating custom LaunchDarkly configurations.
-
#log_timings? ⇒ Boolean
Whether timing information should be logged.
-
#logger ⇒ Logger
The configured logger for the LaunchDarkly client.
-
#read_timeout ⇒ Float
The read timeout for network connections in seconds.
-
#store ⇒ Object
The store for the Faraday HTTP caching library.
-
#stream? ⇒ Boolean
Whether streaming mode should be enabled.
-
#stream_uri ⇒ String
The base URL for the LaunchDarkly streaming server.
Constructor Details
#initialize(opts = {}) ⇒ type
Constructor for creating custom LaunchDarkly configurations.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ldclient-rb/config.rb', line 24 def initialize(opts = {}) @base_uri = (opts[:base_uri] || Config.default_base_uri).chomp("/") @stream_uri = (opts[:stream_uri] || Config.default_stream_uri).chomp("/") @capacity = opts[:capacity] || Config.default_capacity @logger = opts[:logger] || Config.default_logger @store = opts[:store] || Config.default_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 @log_timings = opts[:log_timings] || Config.default_log_timings @stream = opts[:stream] || Config.default_stream @feature_store = opts[:feature_store] || Config.default_feature_store @debug_stream = opts[:debug_stream] || Config.default_debug_stream end |
Class Method Details
.default ⇒ Config
The default LaunchDarkly client configuration. This configuration sets reasonable defaults for most users.
144 145 146 |
# File 'lib/ldclient-rb/config.rb', line 144 def self.default Config.new() end |
.default_base_uri ⇒ Object
152 153 154 |
# File 'lib/ldclient-rb/config.rb', line 152 def self.default_base_uri "https://app.launchdarkly.com" end |
.default_capacity ⇒ Object
148 149 150 |
# File 'lib/ldclient-rb/config.rb', line 148 def self.default_capacity 10000 end |
.default_connect_timeout ⇒ Object
172 173 174 |
# File 'lib/ldclient-rb/config.rb', line 172 def self.default_connect_timeout 2 end |
.default_debug_stream ⇒ Object
192 193 194 |
# File 'lib/ldclient-rb/config.rb', line 192 def self.default_debug_stream false end |
.default_feature_store ⇒ Object
188 189 190 |
# File 'lib/ldclient-rb/config.rb', line 188 def self.default_feature_store nil end |
.default_flush_interval ⇒ Object
164 165 166 |
# File 'lib/ldclient-rb/config.rb', line 164 def self.default_flush_interval 10 end |
.default_log_timings ⇒ Object
180 181 182 |
# File 'lib/ldclient-rb/config.rb', line 180 def self.default_log_timings false end |
.default_logger ⇒ Object
176 177 178 |
# File 'lib/ldclient-rb/config.rb', line 176 def self.default_logger defined?(Rails) && Rails.respond_to?(:logger) ? Rails.logger : ::Logger.new($stdout) end |
.default_read_timeout ⇒ Object
168 169 170 |
# File 'lib/ldclient-rb/config.rb', line 168 def self.default_read_timeout 10 end |
.default_store ⇒ Object
160 161 162 |
# File 'lib/ldclient-rb/config.rb', line 160 def self.default_store defined?(Rails) && Rails.respond_to?(:cache) ? Rails.cache : ThreadSafeMemoryStore.new end |
.default_stream ⇒ Object
184 185 186 |
# File 'lib/ldclient-rb/config.rb', line 184 def self.default_stream true end |
.default_stream_uri ⇒ Object
156 157 158 |
# File 'lib/ldclient-rb/config.rb', line 156 def self.default_stream_uri "https://stream.launchdarkly.com" end |
Instance Method Details
#base_uri ⇒ String
The base URL for the LaunchDarkly server.
43 44 45 |
# File 'lib/ldclient-rb/config.rb', line 43 def base_uri @base_uri end |
#capacity ⇒ Integer
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.
96 97 98 |
# File 'lib/ldclient-rb/config.rb', line 96 def capacity @capacity end |
#connect_timeout ⇒ Float
The connect timeout for network connections in seconds.
120 121 122 |
# File 'lib/ldclient-rb/config.rb', line 120 def connect_timeout @connect_timeout end |
#debug_stream? ⇒ Boolean
Whether we should debug streaming mode. If set, the client will fetch features via polling and compare the retrieved feature with the value in the feature store
69 70 71 |
# File 'lib/ldclient-rb/config.rb', line 69 def debug_stream? @debug_stream end |
#feature_store ⇒ Object
TODO docs
136 137 138 |
# File 'lib/ldclient-rb/config.rb', line 136 def feature_store @feature_store end |
#flush_interval ⇒ Float
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.
78 79 80 |
# File 'lib/ldclient-rb/config.rb', line 78 def flush_interval @flush_interval end |
#log_timings? ⇒ Boolean
Whether timing information should be logged. If it is logged, it will be logged to the DEBUG level on the configured logger. This can be very verbose.
129 130 131 |
# File 'lib/ldclient-rb/config.rb', line 129 def log_timings? @log_timings end |
#logger ⇒ Logger
The configured logger for the LaunchDarkly client. The client library uses the log to print warning and error messages.
87 88 89 |
# File 'lib/ldclient-rb/config.rb', line 87 def logger @logger end |
#read_timeout ⇒ Float
The read timeout for network connections in seconds.
112 113 114 |
# File 'lib/ldclient-rb/config.rb', line 112 def read_timeout @read_timeout end |
#store ⇒ Object
The store for the Faraday HTTP caching library. Stores should respond to ‘read’ and ‘write’ requests.
104 105 106 |
# File 'lib/ldclient-rb/config.rb', line 104 def store @store end |
#stream? ⇒ Boolean
Whether streaming mode should be enabled. Streaming mode asynchronously updates feature flags in real-time using server-sent events.
60 61 62 |
# File 'lib/ldclient-rb/config.rb', line 60 def stream? @stream end |
#stream_uri ⇒ String
The base URL for the LaunchDarkly streaming server.
51 52 53 |
# File 'lib/ldclient-rb/config.rb', line 51 def stream_uri @stream_uri end |