launchdarkly-server-sdk 5.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.circleci/config.yml +134 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.gitignore +15 -0
- data/.hound.yml +2 -0
- data/.rspec +2 -0
- data/.rubocop.yml +600 -0
- data/.simplecov +4 -0
- data/.yardopts +9 -0
- data/CHANGELOG.md +261 -0
- data/CODEOWNERS +1 -0
- data/CONTRIBUTING.md +37 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +102 -0
- data/LICENSE.txt +13 -0
- data/README.md +56 -0
- data/Rakefile +5 -0
- data/azure-pipelines.yml +51 -0
- data/ext/mkrf_conf.rb +11 -0
- data/launchdarkly-server-sdk.gemspec +40 -0
- data/lib/ldclient-rb.rb +29 -0
- data/lib/ldclient-rb/cache_store.rb +45 -0
- data/lib/ldclient-rb/config.rb +411 -0
- data/lib/ldclient-rb/evaluation.rb +455 -0
- data/lib/ldclient-rb/event_summarizer.rb +55 -0
- data/lib/ldclient-rb/events.rb +468 -0
- data/lib/ldclient-rb/expiring_cache.rb +77 -0
- data/lib/ldclient-rb/file_data_source.rb +312 -0
- data/lib/ldclient-rb/flags_state.rb +76 -0
- data/lib/ldclient-rb/impl.rb +13 -0
- data/lib/ldclient-rb/impl/integrations/consul_impl.rb +158 -0
- data/lib/ldclient-rb/impl/integrations/dynamodb_impl.rb +228 -0
- data/lib/ldclient-rb/impl/integrations/redis_impl.rb +155 -0
- data/lib/ldclient-rb/impl/store_client_wrapper.rb +47 -0
- data/lib/ldclient-rb/impl/store_data_set_sorter.rb +55 -0
- data/lib/ldclient-rb/in_memory_store.rb +100 -0
- data/lib/ldclient-rb/integrations.rb +55 -0
- data/lib/ldclient-rb/integrations/consul.rb +38 -0
- data/lib/ldclient-rb/integrations/dynamodb.rb +47 -0
- data/lib/ldclient-rb/integrations/redis.rb +55 -0
- data/lib/ldclient-rb/integrations/util/store_wrapper.rb +230 -0
- data/lib/ldclient-rb/interfaces.rb +153 -0
- data/lib/ldclient-rb/ldclient.rb +424 -0
- data/lib/ldclient-rb/memoized_value.rb +32 -0
- data/lib/ldclient-rb/newrelic.rb +17 -0
- data/lib/ldclient-rb/non_blocking_thread_pool.rb +46 -0
- data/lib/ldclient-rb/polling.rb +78 -0
- data/lib/ldclient-rb/redis_store.rb +87 -0
- data/lib/ldclient-rb/requestor.rb +101 -0
- data/lib/ldclient-rb/simple_lru_cache.rb +25 -0
- data/lib/ldclient-rb/stream.rb +141 -0
- data/lib/ldclient-rb/user_filter.rb +51 -0
- data/lib/ldclient-rb/util.rb +50 -0
- data/lib/ldclient-rb/version.rb +3 -0
- data/scripts/gendocs.sh +11 -0
- data/scripts/release.sh +27 -0
- data/spec/config_spec.rb +63 -0
- data/spec/evaluation_spec.rb +739 -0
- data/spec/event_summarizer_spec.rb +63 -0
- data/spec/events_spec.rb +642 -0
- data/spec/expiring_cache_spec.rb +76 -0
- data/spec/feature_store_spec_base.rb +213 -0
- data/spec/file_data_source_spec.rb +255 -0
- data/spec/fixtures/feature.json +37 -0
- data/spec/fixtures/feature1.json +36 -0
- data/spec/fixtures/user.json +9 -0
- data/spec/flags_state_spec.rb +81 -0
- data/spec/http_util.rb +109 -0
- data/spec/in_memory_feature_store_spec.rb +12 -0
- data/spec/integrations/consul_feature_store_spec.rb +42 -0
- data/spec/integrations/dynamodb_feature_store_spec.rb +105 -0
- data/spec/integrations/store_wrapper_spec.rb +276 -0
- data/spec/ldclient_spec.rb +471 -0
- data/spec/newrelic_spec.rb +5 -0
- data/spec/polling_spec.rb +120 -0
- data/spec/redis_feature_store_spec.rb +95 -0
- data/spec/requestor_spec.rb +214 -0
- data/spec/segment_store_spec_base.rb +95 -0
- data/spec/simple_lru_cache_spec.rb +24 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/store_spec.rb +10 -0
- data/spec/stream_spec.rb +60 -0
- data/spec/user_filter_spec.rb +91 -0
- data/spec/util_spec.rb +17 -0
- data/spec/version_spec.rb +7 -0
- metadata +375 -0
data/Rakefile
ADDED
data/azure-pipelines.yml
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
jobs:
|
2
|
+
- job: build
|
3
|
+
pool:
|
4
|
+
vmImage: 'vs2017-win2016'
|
5
|
+
steps:
|
6
|
+
- task: PowerShell@2
|
7
|
+
displayName: 'Setup Dynamo'
|
8
|
+
inputs:
|
9
|
+
targetType: inline
|
10
|
+
workingDirectory: $(System.DefaultWorkingDirectory)
|
11
|
+
script: |
|
12
|
+
iwr -outf dynamo.zip https://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.zip
|
13
|
+
mkdir dynamo
|
14
|
+
Expand-Archive -Path dynamo.zip -DestinationPath dynamo
|
15
|
+
cd dynamo
|
16
|
+
javaw -D"java.library.path=./DynamoDBLocal_lib" -jar DynamoDBLocal.jar
|
17
|
+
- task: PowerShell@2
|
18
|
+
displayName: 'Setup Consul'
|
19
|
+
inputs:
|
20
|
+
targetType: inline
|
21
|
+
workingDirectory: $(System.DefaultWorkingDirectory)
|
22
|
+
script: |
|
23
|
+
iwr -outf consul.zip https://releases.hashicorp.com/consul/1.4.2/consul_1.4.2_windows_amd64.zip
|
24
|
+
mkdir consul
|
25
|
+
Expand-Archive -Path consul.zip -DestinationPath consul
|
26
|
+
cd consul
|
27
|
+
sc.exe create "Consul" binPath="$(System.DefaultWorkingDirectory)/consul/consul.exe agent -dev"
|
28
|
+
sc.exe start "Consul"
|
29
|
+
- task: PowerShell@2
|
30
|
+
displayName: 'Setup Redis'
|
31
|
+
inputs:
|
32
|
+
targetType: inline
|
33
|
+
workingDirectory: $(System.DefaultWorkingDirectory)
|
34
|
+
script: |
|
35
|
+
iwr -outf redis.zip https://github.com/MicrosoftArchive/redis/releases/download/win-3.0.504/Redis-x64-3.0.504.zip
|
36
|
+
mkdir redis
|
37
|
+
Expand-Archive -Path redis.zip -DestinationPath redis
|
38
|
+
cd redis
|
39
|
+
./redis-server --service-install
|
40
|
+
./redis-server --service-start
|
41
|
+
- task: PowerShell@2
|
42
|
+
displayName: 'Setup SDK and Test'
|
43
|
+
inputs:
|
44
|
+
targetType: inline
|
45
|
+
workingDirectory: $(System.DefaultWorkingDirectory)
|
46
|
+
script: |
|
47
|
+
ruby -v
|
48
|
+
gem install bundler -v 1.17.3
|
49
|
+
bundle install
|
50
|
+
mkdir rspec
|
51
|
+
bundle exec rspec --format progress --format RspecJunitFormatter -o ./rspec/rspec.xml spec
|
data/ext/mkrf_conf.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
|
3
|
+
|
4
|
+
# From http://stackoverflow.com/questions/5830835/how-to-add-openssl-dependency-to-gemspec
|
5
|
+
# the whole reason this file exists: to return an error if openssl
|
6
|
+
# isn't installed.
|
7
|
+
require "openssl"
|
8
|
+
|
9
|
+
f = File.open(File.join(File.dirname(__FILE__), "Rakefile"), "w") # create dummy rakefile to indicate success
|
10
|
+
f.write("task :default\n")
|
11
|
+
f.close
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "ldclient-rb/version"
|
6
|
+
|
7
|
+
# rubocop:disable Metrics/BlockLength
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = "launchdarkly-server-sdk"
|
10
|
+
spec.version = LaunchDarkly::VERSION
|
11
|
+
spec.authors = ["LaunchDarkly"]
|
12
|
+
spec.email = ["team@launchdarkly.com"]
|
13
|
+
spec.summary = "LaunchDarkly SDK for Ruby"
|
14
|
+
spec.description = "Official LaunchDarkly SDK for Ruby"
|
15
|
+
spec.homepage = "https://github.com/launchdarkly/ruby-server-sdk"
|
16
|
+
spec.license = "Apache-2.0"
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0")
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
spec.extensions = 'ext/mkrf_conf.rb'
|
23
|
+
|
24
|
+
spec.add_development_dependency "aws-sdk-dynamodb", "~> 1.18"
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.2"
|
27
|
+
spec.add_development_dependency "codeclimate-test-reporter", "~> 0"
|
28
|
+
spec.add_development_dependency "diplomat", ">= 2.0.2"
|
29
|
+
spec.add_development_dependency "redis", "~> 3.3.5"
|
30
|
+
spec.add_development_dependency "connection_pool", ">= 2.1.2"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "rspec_junit_formatter", "~> 0.3.0"
|
33
|
+
spec.add_development_dependency "timecop", "~> 0.9.1"
|
34
|
+
spec.add_development_dependency "listen", "~> 3.0" # see file_data_source.rb
|
35
|
+
|
36
|
+
spec.add_runtime_dependency "json", [">= 1.8", "< 3"]
|
37
|
+
spec.add_runtime_dependency "semantic", "~> 1.6"
|
38
|
+
spec.add_runtime_dependency "concurrent-ruby", "~> 1.0"
|
39
|
+
spec.add_runtime_dependency "ld-eventsource", '~> 1.0'
|
40
|
+
end
|
data/lib/ldclient-rb.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# Namespace for the LaunchDarkly Ruby SDK.
|
4
|
+
#
|
5
|
+
module LaunchDarkly
|
6
|
+
end
|
7
|
+
|
8
|
+
require "ldclient-rb/version"
|
9
|
+
require "ldclient-rb/interfaces"
|
10
|
+
require "ldclient-rb/util"
|
11
|
+
require "ldclient-rb/evaluation"
|
12
|
+
require "ldclient-rb/flags_state"
|
13
|
+
require "ldclient-rb/ldclient"
|
14
|
+
require "ldclient-rb/cache_store"
|
15
|
+
require "ldclient-rb/expiring_cache"
|
16
|
+
require "ldclient-rb/memoized_value"
|
17
|
+
require "ldclient-rb/in_memory_store"
|
18
|
+
require "ldclient-rb/config"
|
19
|
+
require "ldclient-rb/newrelic"
|
20
|
+
require "ldclient-rb/stream"
|
21
|
+
require "ldclient-rb/polling"
|
22
|
+
require "ldclient-rb/user_filter"
|
23
|
+
require "ldclient-rb/simple_lru_cache"
|
24
|
+
require "ldclient-rb/non_blocking_thread_pool"
|
25
|
+
require "ldclient-rb/event_summarizer"
|
26
|
+
require "ldclient-rb/events"
|
27
|
+
require "ldclient-rb/requestor"
|
28
|
+
require "ldclient-rb/file_data_source"
|
29
|
+
require "ldclient-rb/integrations"
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "concurrent/map"
|
2
|
+
|
3
|
+
module LaunchDarkly
|
4
|
+
#
|
5
|
+
# A thread-safe in-memory store that uses the same semantics that Faraday would expect, although we
|
6
|
+
# no longer use Faraday. This is used by Requestor, when we are not in a Rails environment.
|
7
|
+
#
|
8
|
+
# @private
|
9
|
+
#
|
10
|
+
class ThreadSafeMemoryStore
|
11
|
+
#
|
12
|
+
# Default constructor
|
13
|
+
#
|
14
|
+
# @return [ThreadSafeMemoryStore] a new store
|
15
|
+
def initialize
|
16
|
+
@cache = Concurrent::Map.new
|
17
|
+
end
|
18
|
+
|
19
|
+
#
|
20
|
+
# Read a value from the cache
|
21
|
+
# @param key [Object] the cache key
|
22
|
+
#
|
23
|
+
# @return [Object] the cache value
|
24
|
+
def read(key)
|
25
|
+
@cache[key]
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# Store a value in the cache
|
30
|
+
# @param key [Object] the cache key
|
31
|
+
# @param value [Object] the value to associate with the key
|
32
|
+
#
|
33
|
+
# @return [Object] the value
|
34
|
+
def write(key, value)
|
35
|
+
@cache[key] = value
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
# Delete a value in the cache
|
40
|
+
# @param key [Object] the cache key
|
41
|
+
def delete(key)
|
42
|
+
@cache.delete(key)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,411 @@
|
|
1
|
+
require "logger"
|
2
|
+
|
3
|
+
module LaunchDarkly
|
4
|
+
#
|
5
|
+
# This class exposes advanced configuration options for the LaunchDarkly
|
6
|
+
# client library. Most users will not need to use a custom configuration--
|
7
|
+
# the default configuration sets sane defaults for most use cases.
|
8
|
+
#
|
9
|
+
#
|
10
|
+
class Config
|
11
|
+
# rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
|
12
|
+
|
13
|
+
#
|
14
|
+
# Constructor for creating custom LaunchDarkly configurations.
|
15
|
+
#
|
16
|
+
# @param opts [Hash] the configuration options
|
17
|
+
# @option opts [Logger] :logger See {#logger}.
|
18
|
+
# @option opts [String] :base_uri ("https://app.launchdarkly.com") See {#base_uri}.
|
19
|
+
# @option opts [String] :stream_uri ("https://stream.launchdarkly.com") See {#stream_uri}.
|
20
|
+
# @option opts [String] :events_uri ("https://events.launchdarkly.com") See {#events_uri}.
|
21
|
+
# @option opts [Integer] :capacity (10000) See {#capacity}.
|
22
|
+
# @option opts [Float] :flush_interval (30) See {#flush_interval}.
|
23
|
+
# @option opts [Float] :read_timeout (10) See {#read_timeout}.
|
24
|
+
# @option opts [Float] :connect_timeout (2) See {#connect_timeout}.
|
25
|
+
# @option opts [Object] :cache_store See {#cache_store}.
|
26
|
+
# @option opts [Object] :feature_store See {#feature_store}.
|
27
|
+
# @option opts [Boolean] :use_ldd (false) See {#use_ldd?}.
|
28
|
+
# @option opts [Boolean] :offline (false) See {#offline?}.
|
29
|
+
# @option opts [Float] :poll_interval (30) See {#poll_interval}.
|
30
|
+
# @option opts [Boolean] :stream (true) See {#stream?}.
|
31
|
+
# @option opts [Boolean] all_attributes_private (false) See {#all_attributes_private}.
|
32
|
+
# @option opts [Array] :private_attribute_names See {#private_attribute_names}.
|
33
|
+
# @option opts [Boolean] :send_events (true) See {#send_events}.
|
34
|
+
# @option opts [Integer] :user_keys_capacity (1000) See {#user_keys_capacity}.
|
35
|
+
# @option opts [Float] :user_keys_flush_interval (300) See {#user_keys_flush_interval}.
|
36
|
+
# @option opts [Boolean] :inline_users_in_events (false) See {#inline_users_in_events}.
|
37
|
+
# @option opts [Object] :data_source See {#data_source}.
|
38
|
+
# @option opts [Object] :update_processor Obsolete synonym for `data_source`.
|
39
|
+
# @option opts [Object] :update_processor_factory Obsolete synonym for `data_source`.
|
40
|
+
#
|
41
|
+
def initialize(opts = {})
|
42
|
+
@base_uri = (opts[:base_uri] || Config.default_base_uri).chomp("/")
|
43
|
+
@stream_uri = (opts[:stream_uri] || Config.default_stream_uri).chomp("/")
|
44
|
+
@events_uri = (opts[:events_uri] || Config.default_events_uri).chomp("/")
|
45
|
+
@capacity = opts[:capacity] || Config.default_capacity
|
46
|
+
@logger = opts[:logger] || Config.default_logger
|
47
|
+
@cache_store = opts[:cache_store] || Config.default_cache_store
|
48
|
+
@flush_interval = opts[:flush_interval] || Config.default_flush_interval
|
49
|
+
@connect_timeout = opts[:connect_timeout] || Config.default_connect_timeout
|
50
|
+
@read_timeout = opts[:read_timeout] || Config.default_read_timeout
|
51
|
+
@feature_store = opts[:feature_store] || Config.default_feature_store
|
52
|
+
@stream = opts.has_key?(:stream) ? opts[:stream] : Config.default_stream
|
53
|
+
@use_ldd = opts.has_key?(:use_ldd) ? opts[:use_ldd] : Config.default_use_ldd
|
54
|
+
@offline = opts.has_key?(:offline) ? opts[:offline] : Config.default_offline
|
55
|
+
@poll_interval = opts.has_key?(:poll_interval) && opts[:poll_interval] > Config.default_poll_interval ? opts[:poll_interval] : Config.default_poll_interval
|
56
|
+
@all_attributes_private = opts[:all_attributes_private] || false
|
57
|
+
@private_attribute_names = opts[:private_attribute_names] || []
|
58
|
+
@send_events = opts.has_key?(:send_events) ? opts[:send_events] : Config.default_send_events
|
59
|
+
@user_keys_capacity = opts[:user_keys_capacity] || Config.default_user_keys_capacity
|
60
|
+
@user_keys_flush_interval = opts[:user_keys_flush_interval] || Config.default_user_keys_flush_interval
|
61
|
+
@inline_users_in_events = opts[:inline_users_in_events] || false
|
62
|
+
@data_source = opts[:data_source] || opts[:update_processor] || opts[:update_processor_factory]
|
63
|
+
@update_processor = opts[:update_processor]
|
64
|
+
@update_processor_factory = opts[:update_processor_factory]
|
65
|
+
end
|
66
|
+
|
67
|
+
#
|
68
|
+
# The base URL for the LaunchDarkly server. This is configurable mainly for testing
|
69
|
+
# purposes; most users should use the default value.
|
70
|
+
# @return [String]
|
71
|
+
#
|
72
|
+
attr_reader :base_uri
|
73
|
+
|
74
|
+
#
|
75
|
+
# The base URL for the LaunchDarkly streaming server. This is configurable mainly for testing
|
76
|
+
# purposes; most users should use the default value.
|
77
|
+
# @return [String]
|
78
|
+
#
|
79
|
+
attr_reader :stream_uri
|
80
|
+
|
81
|
+
#
|
82
|
+
# The base URL for the LaunchDarkly events server. This is configurable mainly for testing
|
83
|
+
# purposes; most users should use the default value.
|
84
|
+
# @return [String]
|
85
|
+
#
|
86
|
+
attr_reader :events_uri
|
87
|
+
|
88
|
+
#
|
89
|
+
# Whether streaming mode should be enabled. Streaming mode asynchronously updates
|
90
|
+
# feature flags in real-time using server-sent events. Streaming is enabled by default, and
|
91
|
+
# should only be disabled on the advice of LaunchDarkly support.
|
92
|
+
# @return [Boolean]
|
93
|
+
#
|
94
|
+
def stream?
|
95
|
+
@stream
|
96
|
+
end
|
97
|
+
|
98
|
+
#
|
99
|
+
# Whether to use the LaunchDarkly relay proxy in daemon mode. In this mode, the client does not
|
100
|
+
# use polling or streaming to get feature flag updates from the server, but instead reads them
|
101
|
+
# from the {#feature_store feature store}, which is assumed to be a database that is populated by
|
102
|
+
# a LaunchDarkly relay proxy. For more information, see ["The relay proxy"](https://docs.launchdarkly.com/v2.0/docs/the-relay-proxy)
|
103
|
+
# and ["Using a persistent feature store"](https://docs.launchdarkly.com/v2.0/docs/using-a-persistent-feature-store).
|
104
|
+
#
|
105
|
+
# All other properties related to streaming or polling are ignored if this option is set to true.
|
106
|
+
#
|
107
|
+
# @return [Boolean]
|
108
|
+
#
|
109
|
+
def use_ldd?
|
110
|
+
@use_ldd
|
111
|
+
end
|
112
|
+
|
113
|
+
#
|
114
|
+
# Whether the client should be initialized in offline mode. In offline mode, default values are
|
115
|
+
# returned for all flags and no remote network requests are made.
|
116
|
+
# @return [Boolean]
|
117
|
+
#
|
118
|
+
def offline?
|
119
|
+
@offline
|
120
|
+
end
|
121
|
+
|
122
|
+
#
|
123
|
+
# The number of seconds between flushes of the event buffer. Decreasing the flush interval means
|
124
|
+
# that the event buffer is less likely to reach capacity.
|
125
|
+
# @return [Float]
|
126
|
+
#
|
127
|
+
attr_reader :flush_interval
|
128
|
+
|
129
|
+
#
|
130
|
+
# The number of seconds to wait before polling for feature flag updates. This option has no
|
131
|
+
# effect unless streaming is disabled.
|
132
|
+
# @return [Float]
|
133
|
+
#
|
134
|
+
attr_reader :poll_interval
|
135
|
+
|
136
|
+
#
|
137
|
+
# The configured logger for the LaunchDarkly client. The client library uses the log to
|
138
|
+
# print warning and error messages. If not specified, this defaults to the Rails logger
|
139
|
+
# in a Rails environment, or stdout otherwise.
|
140
|
+
# @return [Logger]
|
141
|
+
#
|
142
|
+
attr_reader :logger
|
143
|
+
|
144
|
+
#
|
145
|
+
# The capacity of the events buffer. The client buffers up to this many
|
146
|
+
# events in memory before flushing. If the capacity is exceeded before
|
147
|
+
# the buffer is flushed, events will be discarded.
|
148
|
+
# Increasing the capacity means that events are less likely to be discarded,
|
149
|
+
# at the cost of consuming more memory.
|
150
|
+
# @return [Integer]
|
151
|
+
#
|
152
|
+
attr_reader :capacity
|
153
|
+
|
154
|
+
#
|
155
|
+
# A store for HTTP caching (used only in polling mode). This must support the semantics used by
|
156
|
+
# the [`faraday-http-cache`](https://github.com/plataformatec/faraday-http-cache) gem, although
|
157
|
+
# the SDK no longer uses Faraday. Defaults to the Rails cache in a Rails environment, or a
|
158
|
+
# thread-safe in-memory store otherwise.
|
159
|
+
# @return [Object]
|
160
|
+
#
|
161
|
+
attr_reader :cache_store
|
162
|
+
|
163
|
+
#
|
164
|
+
# The read timeout for network connections in seconds. This does not apply to the streaming
|
165
|
+
# connection, which uses a longer timeout since the server does not send data constantly.
|
166
|
+
# @return [Float]
|
167
|
+
#
|
168
|
+
attr_reader :read_timeout
|
169
|
+
|
170
|
+
#
|
171
|
+
# The connect timeout for network connections in seconds.
|
172
|
+
# @return [Float]
|
173
|
+
#
|
174
|
+
attr_reader :connect_timeout
|
175
|
+
|
176
|
+
#
|
177
|
+
# A store for feature flags and related data. The client uses it to store all data received
|
178
|
+
# from LaunchDarkly, and uses the last stored data when evaluating flags. Defaults to
|
179
|
+
# {InMemoryFeatureStore}; for other implementations, see {LaunchDarkly::Integrations}.
|
180
|
+
#
|
181
|
+
# For more information, see ["Using a persistent feature store"](https://docs.launchdarkly.com/v2.0/docs/using-a-persistent-feature-store).
|
182
|
+
#
|
183
|
+
# @return [LaunchDarkly::Interfaces::FeatureStore]
|
184
|
+
#
|
185
|
+
attr_reader :feature_store
|
186
|
+
|
187
|
+
#
|
188
|
+
# True if all user attributes (other than the key) should be considered private. This means
|
189
|
+
# that the attribute values will not be sent to LaunchDarkly in analytics events and will not
|
190
|
+
# appear on the LaunchDarkly dashboard.
|
191
|
+
# @return [Boolean]
|
192
|
+
# @see #private_attribute_names
|
193
|
+
#
|
194
|
+
attr_reader :all_attributes_private
|
195
|
+
|
196
|
+
#
|
197
|
+
# A list of user attribute names that should always be considered private. This means that the
|
198
|
+
# attribute values will not be sent to LaunchDarkly in analytics events and will not appear on
|
199
|
+
# the LaunchDarkly dashboard.
|
200
|
+
#
|
201
|
+
# You can also specify the same behavior for an individual flag evaluation by storing an array
|
202
|
+
# of attribute names in the `:privateAttributeNames` property (note camelcase name) of the
|
203
|
+
# user object.
|
204
|
+
#
|
205
|
+
# @return [Array<String>]
|
206
|
+
# @see #all_attributes_private
|
207
|
+
#
|
208
|
+
attr_reader :private_attribute_names
|
209
|
+
|
210
|
+
#
|
211
|
+
# Whether to send events back to LaunchDarkly. This differs from {#offline?} in that it affects
|
212
|
+
# only the sending of client-side events, not streaming or polling for events from the server.
|
213
|
+
# @return [Boolean]
|
214
|
+
#
|
215
|
+
attr_reader :send_events
|
216
|
+
|
217
|
+
#
|
218
|
+
# The number of user keys that the event processor can remember at any one time. This reduces the
|
219
|
+
# amount of duplicate user details sent in analytics events.
|
220
|
+
# @return [Integer]
|
221
|
+
# @see #user_keys_flush_interval
|
222
|
+
#
|
223
|
+
attr_reader :user_keys_capacity
|
224
|
+
|
225
|
+
#
|
226
|
+
# The interval in seconds at which the event processor will reset its set of known user keys.
|
227
|
+
# @return [Float]
|
228
|
+
# @see #user_keys_capacity
|
229
|
+
#
|
230
|
+
attr_reader :user_keys_flush_interval
|
231
|
+
|
232
|
+
#
|
233
|
+
# Whether to include full user details in every analytics event. By default, events will only
|
234
|
+
# include the user key, except for one "index" event that provides the full details for the user.
|
235
|
+
# The only reason to change this is if you are using the Analytics Data Stream.
|
236
|
+
# @return [Boolean]
|
237
|
+
#
|
238
|
+
attr_reader :inline_users_in_events
|
239
|
+
|
240
|
+
#
|
241
|
+
# An object that is responsible for receiving feature flag data from LaunchDarkly. By default,
|
242
|
+
# the client uses its standard polling or streaming implementation; this is customizable for
|
243
|
+
# testing purposes.
|
244
|
+
#
|
245
|
+
# This may be set to either an object that conforms to {LaunchDarkly::Interfaces::DataSource},
|
246
|
+
# or a lambda (or Proc) that takes two parameters-- SDK key and {Config}-- and returns such an
|
247
|
+
# object.
|
248
|
+
#
|
249
|
+
# @return [LaunchDarkly::Interfaces::DataSource|lambda]
|
250
|
+
# @see FileDataSource
|
251
|
+
#
|
252
|
+
attr_reader :data_source
|
253
|
+
|
254
|
+
# @deprecated This is replaced by {#data_source}.
|
255
|
+
attr_reader :update_processor
|
256
|
+
|
257
|
+
# @deprecated This is replaced by {#data_source}.
|
258
|
+
attr_reader :update_processor_factory
|
259
|
+
|
260
|
+
#
|
261
|
+
# The default LaunchDarkly client configuration. This configuration sets
|
262
|
+
# reasonable defaults for most users.
|
263
|
+
# @return [Config] The default LaunchDarkly configuration.
|
264
|
+
#
|
265
|
+
def self.default
|
266
|
+
Config.new
|
267
|
+
end
|
268
|
+
|
269
|
+
#
|
270
|
+
# The default value for {#capacity}.
|
271
|
+
# @return [Integer] 10000
|
272
|
+
#
|
273
|
+
def self.default_capacity
|
274
|
+
10000
|
275
|
+
end
|
276
|
+
|
277
|
+
#
|
278
|
+
# The default value for {#base_uri}.
|
279
|
+
# @return [String] "https://app.launchdarkly.com"
|
280
|
+
#
|
281
|
+
def self.default_base_uri
|
282
|
+
"https://app.launchdarkly.com"
|
283
|
+
end
|
284
|
+
|
285
|
+
#
|
286
|
+
# The default value for {#stream_uri}.
|
287
|
+
# @return [String] "https://stream.launchdarkly.com"
|
288
|
+
#
|
289
|
+
def self.default_stream_uri
|
290
|
+
"https://stream.launchdarkly.com"
|
291
|
+
end
|
292
|
+
|
293
|
+
#
|
294
|
+
# The default value for {#events_uri}.
|
295
|
+
# @return [String] "https://events.launchdarkly.com"
|
296
|
+
#
|
297
|
+
def self.default_events_uri
|
298
|
+
"https://events.launchdarkly.com"
|
299
|
+
end
|
300
|
+
|
301
|
+
#
|
302
|
+
# The default value for {#cache_store}.
|
303
|
+
# @return [Object] the Rails cache if in Rails, or a simple in-memory implementation otherwise
|
304
|
+
#
|
305
|
+
def self.default_cache_store
|
306
|
+
defined?(Rails) && Rails.respond_to?(:cache) ? Rails.cache : ThreadSafeMemoryStore.new
|
307
|
+
end
|
308
|
+
|
309
|
+
#
|
310
|
+
# The default value for {#flush_interval}.
|
311
|
+
# @return [Float] 10
|
312
|
+
#
|
313
|
+
def self.default_flush_interval
|
314
|
+
10
|
315
|
+
end
|
316
|
+
|
317
|
+
#
|
318
|
+
# The default value for {#read_timeout}.
|
319
|
+
# @return [Float] 10
|
320
|
+
#
|
321
|
+
def self.default_read_timeout
|
322
|
+
10
|
323
|
+
end
|
324
|
+
|
325
|
+
#
|
326
|
+
# The default value for {#connect_timeout}.
|
327
|
+
# @return [Float] 10
|
328
|
+
#
|
329
|
+
def self.default_connect_timeout
|
330
|
+
2
|
331
|
+
end
|
332
|
+
|
333
|
+
#
|
334
|
+
# The default value for {#logger}.
|
335
|
+
# @return [Logger] the Rails logger if in Rails, or a default Logger at WARN level otherwise
|
336
|
+
#
|
337
|
+
def self.default_logger
|
338
|
+
if defined?(Rails) && Rails.respond_to?(:logger)
|
339
|
+
Rails.logger
|
340
|
+
else
|
341
|
+
log = ::Logger.new($stdout)
|
342
|
+
log.level = ::Logger::WARN
|
343
|
+
log
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
347
|
+
#
|
348
|
+
# The default value for {#stream?}.
|
349
|
+
# @return [Boolean] true
|
350
|
+
#
|
351
|
+
def self.default_stream
|
352
|
+
true
|
353
|
+
end
|
354
|
+
|
355
|
+
#
|
356
|
+
# The default value for {#use_ldd?}.
|
357
|
+
# @return [Boolean] false
|
358
|
+
#
|
359
|
+
def self.default_use_ldd
|
360
|
+
false
|
361
|
+
end
|
362
|
+
|
363
|
+
#
|
364
|
+
# The default value for {#feature_store}.
|
365
|
+
# @return [LaunchDarkly::Interfaces::FeatureStore] an {InMemoryFeatureStore}
|
366
|
+
#
|
367
|
+
def self.default_feature_store
|
368
|
+
InMemoryFeatureStore.new
|
369
|
+
end
|
370
|
+
|
371
|
+
#
|
372
|
+
# The default value for {#offline?}.
|
373
|
+
# @return [Boolean] false
|
374
|
+
#
|
375
|
+
def self.default_offline
|
376
|
+
false
|
377
|
+
end
|
378
|
+
|
379
|
+
#
|
380
|
+
# The default value for {#poll_interval}.
|
381
|
+
# @return [Float] 30
|
382
|
+
#
|
383
|
+
def self.default_poll_interval
|
384
|
+
30
|
385
|
+
end
|
386
|
+
|
387
|
+
#
|
388
|
+
# The default value for {#send_events}.
|
389
|
+
# @return [Boolean] true
|
390
|
+
#
|
391
|
+
def self.default_send_events
|
392
|
+
true
|
393
|
+
end
|
394
|
+
|
395
|
+
#
|
396
|
+
# The default value for {#user_keys_capacity}.
|
397
|
+
# @return [Integer] 1000
|
398
|
+
#
|
399
|
+
def self.default_user_keys_capacity
|
400
|
+
1000
|
401
|
+
end
|
402
|
+
|
403
|
+
#
|
404
|
+
# The default value for {#user_keys_flush_interval}.
|
405
|
+
# @return [Float] 300
|
406
|
+
#
|
407
|
+
def self.default_user_keys_flush_interval
|
408
|
+
300
|
409
|
+
end
|
410
|
+
end
|
411
|
+
end
|