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_flush_interval ⇒ Object
- .default_log_timings ⇒ Object
- .default_logger ⇒ Object
- .default_read_timeout ⇒ Object
- .default_store ⇒ 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.
-
#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.
Constructor Details
#initialize(opts = {}) ⇒ type
Constructor for creating custom LaunchDarkly configurations.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ldclient-rb/config.rb', line 24 def initialize(opts = {}) @base_uri = (opts[:base_uri] || Config.default_base_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 end |
Class Method Details
.default ⇒ Config
The default LaunchDarkly client configuration. This configuration sets reasonable defaults for most users.
107 108 109 |
# File 'lib/ldclient-rb/config.rb', line 107 def self.default Config.new() end |
.default_base_uri ⇒ Object
115 116 117 |
# File 'lib/ldclient-rb/config.rb', line 115 def self.default_base_uri "https://app.launchdarkly.com" end |
.default_capacity ⇒ Object
111 112 113 |
# File 'lib/ldclient-rb/config.rb', line 111 def self.default_capacity 10000 end |
.default_connect_timeout ⇒ Object
131 132 133 |
# File 'lib/ldclient-rb/config.rb', line 131 def self.default_connect_timeout 2 end |
.default_flush_interval ⇒ Object
123 124 125 |
# File 'lib/ldclient-rb/config.rb', line 123 def self.default_flush_interval 10 end |
.default_log_timings ⇒ Object
139 140 141 |
# File 'lib/ldclient-rb/config.rb', line 139 def self.default_log_timings false end |
.default_logger ⇒ Object
135 136 137 |
# File 'lib/ldclient-rb/config.rb', line 135 def self.default_logger defined?(Rails) && Rails.respond_to?(:logger) ? Rails.logger : ::Logger.new($stdout) end |
.default_read_timeout ⇒ Object
127 128 129 |
# File 'lib/ldclient-rb/config.rb', line 127 def self.default_read_timeout 10 end |
.default_store ⇒ Object
119 120 121 |
# File 'lib/ldclient-rb/config.rb', line 119 def self.default_store defined?(Rails) && Rails.respond_to?(:cache) ? Rails.cache : ThreadSafeMemoryStore.new end |
Instance Method Details
#base_uri ⇒ String
The base URL for the LaunchDarkly server.
39 40 41 |
# File 'lib/ldclient-rb/config.rb', line 39 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.
66 67 68 |
# File 'lib/ldclient-rb/config.rb', line 66 def capacity @capacity end |
#connect_timeout ⇒ Float
The connect timeout for network connections in seconds.
90 91 92 |
# File 'lib/ldclient-rb/config.rb', line 90 def connect_timeout @connect_timeout 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.
48 49 50 |
# File 'lib/ldclient-rb/config.rb', line 48 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.
99 100 101 |
# File 'lib/ldclient-rb/config.rb', line 99 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.
57 58 59 |
# File 'lib/ldclient-rb/config.rb', line 57 def logger @logger end |
#read_timeout ⇒ Float
The read timeout for network connections in seconds.
82 83 84 |
# File 'lib/ldclient-rb/config.rb', line 82 def read_timeout @read_timeout end |
#store ⇒ Object
The store for the Faraday HTTP caching library. Stores should respond to ‘read’ and ‘write’ requests.
74 75 76 |
# File 'lib/ldclient-rb/config.rb', line 74 def store @store end |