Skip to content

Commit 8b78a4f

Browse files
authored
Merge pull request #126 from launchdarkly/eb/ch60407/rename-intfs
(6.0 - #4) rename FeatureStore to DataStore
2 parents ae89808 + 38493b9 commit 8b78a4f

27 files changed

+205
-215
lines changed

lib/ldclient-rb/config.rb

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Config
2323
# @option opts [Float] :read_timeout (10) See {#read_timeout}.
2424
# @option opts [Float] :connect_timeout (2) See {#connect_timeout}.
2525
# @option opts [Object] :cache_store See {#cache_store}.
26-
# @option opts [Object] :feature_store See {#feature_store}.
26+
# @option opts [Object] :data_store See {#data_store}.
2727
# @option opts [Boolean] :use_ldd (false) See {#use_ldd?}.
2828
# @option opts [Boolean] :offline (false) See {#offline?}.
2929
# @option opts [Float] :poll_interval (30) See {#poll_interval}.
@@ -35,8 +35,6 @@ class Config
3535
# @option opts [Float] :user_keys_flush_interval (300) See {#user_keys_flush_interval}.
3636
# @option opts [Boolean] :inline_users_in_events (false) See {#inline_users_in_events}.
3737
# @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`.
4038
#
4139
def initialize(opts = {})
4240
@base_uri = (opts[:base_uri] || Config.default_base_uri).chomp("/")
@@ -48,7 +46,7 @@ def initialize(opts = {})
4846
@flush_interval = opts[:flush_interval] || Config.default_flush_interval
4947
@connect_timeout = opts[:connect_timeout] || Config.default_connect_timeout
5048
@read_timeout = opts[:read_timeout] || Config.default_read_timeout
51-
@feature_store = opts[:feature_store] || Config.default_feature_store
49+
@data_store = opts[:data_store] || Config.default_data_store
5250
@stream = opts.has_key?(:stream) ? opts[:stream] : Config.default_stream
5351
@use_ldd = opts.has_key?(:use_ldd) ? opts[:use_ldd] : Config.default_use_ldd
5452
@offline = opts.has_key?(:offline) ? opts[:offline] : Config.default_offline
@@ -59,9 +57,7 @@ def initialize(opts = {})
5957
@user_keys_capacity = opts[:user_keys_capacity] || Config.default_user_keys_capacity
6058
@user_keys_flush_interval = opts[:user_keys_flush_interval] || Config.default_user_keys_flush_interval
6159
@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]
60+
@data_source = opts[:data_source]
6561
end
6662

6763
#
@@ -98,9 +94,9 @@ def stream?
9894
#
9995
# Whether to use the LaunchDarkly relay proxy in daemon mode. In this mode, the client does not
10096
# 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
97+
# from the {#data_store data store}, which is assumed to be a database that is populated by
10298
# 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).
99+
# and ["Using a persistent data store"](https://docs.launchdarkly.com/v2.0/docs/using-a-persistent-feature-store).
104100
#
105101
# All other properties related to streaming or polling are ignored if this option is set to true.
106102
#
@@ -176,13 +172,13 @@ def offline?
176172
#
177173
# A store for feature flags and related data. The client uses it to store all data received
178174
# from LaunchDarkly, and uses the last stored data when evaluating flags. Defaults to
179-
# {InMemoryFeatureStore}; for other implementations, see {LaunchDarkly::Integrations}.
175+
# {InMemoryDataStore}; for other implementations, see {LaunchDarkly::Integrations}.
180176
#
181-
# For more information, see ["Using a persistent feature store"](https://docs.launchdarkly.com/v2.0/docs/using-a-persistent-feature-store).
177+
# For more information, see ["Using a persistent data store"](https://docs.launchdarkly.com/v2.0/docs/using-a-persistent-feature-store).
182178
#
183-
# @return [LaunchDarkly::Interfaces::FeatureStore]
179+
# @return [LaunchDarkly::Interfaces::DataStore]
184180
#
185-
attr_reader :feature_store
181+
attr_reader :data_store
186182

187183
#
188184
# True if all user attributes (other than the key) should be considered private. This means
@@ -251,12 +247,6 @@ def offline?
251247
#
252248
attr_reader :data_source
253249

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-
260250
#
261251
# The default LaunchDarkly client configuration. This configuration sets
262252
# reasonable defaults for most users.
@@ -361,11 +351,11 @@ def self.default_use_ldd
361351
end
362352

363353
#
364-
# The default value for {#feature_store}.
365-
# @return [LaunchDarkly::Interfaces::FeatureStore] an {InMemoryFeatureStore}
354+
# The default value for {#data_store}.
355+
# @return [LaunchDarkly::Interfaces::DataStore] an {InMemoryDataStore}
366356
#
367-
def self.default_feature_store
368-
InMemoryFeatureStore.new
357+
def self.default_data_store
358+
InMemoryDataStore.new
369359
end
370360

371361
#

lib/ldclient-rb/file_data_source.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ class FileDataSource
118118
# @return an object that can be stored in {Config#data_source}
119119
#
120120
def self.factory(options={})
121-
return lambda { |sdk_key, config| FileDataSourceImpl.new(config.feature_store, config.logger, options) }
121+
return lambda { |sdk_key, config| FileDataSourceImpl.new(config.data_store, config.logger, options) }
122122
end
123123
end
124124

125125
# @private
126126
class FileDataSourceImpl
127-
def initialize(feature_store, logger, options={})
128-
@feature_store = feature_store
127+
def initialize(data_store, logger, options={})
128+
@data_store = data_store
129129
@logger = logger
130130
@paths = options[:paths] || []
131131
if @paths.is_a? String
@@ -187,7 +187,7 @@ def load_all
187187
return
188188
end
189189
end
190-
@feature_store.init(all_data)
190+
@data_store.init(all_data)
191191
@initialized.make_true
192192
end
193193

lib/ldclient-rb/impl/integrations/consul_impl.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ module Impl
55
module Integrations
66
module Consul
77
#
8-
# Internal implementation of the Consul feature store, intended to be used with CachingStoreWrapper.
8+
# Internal implementation of the Consul data store, intended to be used with CachingStoreWrapper.
99
#
10-
class ConsulFeatureStoreCore
10+
class ConsulDataStoreCore
1111
begin
1212
require "diplomat"
1313
CONSUL_ENABLED = true
@@ -17,14 +17,14 @@ class ConsulFeatureStoreCore
1717

1818
def initialize(opts)
1919
if !CONSUL_ENABLED
20-
raise RuntimeError.new("can't use Consul feature store without the 'diplomat' gem")
20+
raise RuntimeError.new("can't use Consul data store without the 'diplomat' gem")
2121
end
2222

2323
@prefix = (opts[:prefix] || LaunchDarkly::Integrations::Consul.default_prefix) + '/'
2424
@logger = opts[:logger] || Config.default_logger
2525
Diplomat.configuration = opts[:consul_config] if !opts[:consul_config].nil?
2626
Diplomat.configuration.url = opts[:url] if !opts[:url].nil?
27-
@logger.info("ConsulFeatureStore: using Consul host at #{Diplomat.configuration.url}")
27+
@logger.info("ConsulDataStore: using Consul host at #{Diplomat.configuration.url}")
2828
end
2929

3030
def init_internal(all_data)
@@ -90,7 +90,7 @@ def upsert_internal(kind, new_item)
9090
else
9191
old_item = Model.deserialize(kind, old_value[0]["Value"])
9292
# Check whether the item is stale. If so, don't do the update (and return the existing item to
93-
# FeatureStoreWrapper so it can be cached)
93+
# DataStoreWrapper so it can be cached)
9494
if old_item[:version] >= new_item[:version]
9595
return old_item
9696
end

lib/ldclient-rb/impl/integrations/dynamodb_impl.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ module Impl
55
module Integrations
66
module DynamoDB
77
#
8-
# Internal implementation of the DynamoDB feature store, intended to be used with CachingStoreWrapper.
8+
# Internal implementation of the DynamoDB data store, intended to be used with CachingStoreWrapper.
99
#
10-
class DynamoDBFeatureStoreCore
10+
class DynamoDBDataStoreCore
1111
begin
1212
require "aws-sdk-dynamodb"
1313
AWS_SDK_ENABLED = true
@@ -28,7 +28,7 @@ class DynamoDBFeatureStoreCore
2828

2929
def initialize(table_name, opts)
3030
if !AWS_SDK_ENABLED
31-
raise RuntimeError.new("can't use DynamoDB feature store without the aws-sdk or aws-sdk-dynamodb gem")
31+
raise RuntimeError.new("can't use DynamoDB data store without the aws-sdk or aws-sdk-dynamodb gem")
3232
end
3333

3434
@table_name = table_name
@@ -41,7 +41,7 @@ def initialize(table_name, opts)
4141
@client = Aws::DynamoDB::Client.new(opts[:dynamodb_opts] || {})
4242
end
4343

44-
@logger.info("DynamoDBFeatureStore: using DynamoDB table \"#{table_name}\"")
44+
@logger.info("DynamoDBDataStore: using DynamoDB table \"#{table_name}\"")
4545
end
4646

4747
def init_internal(all_data)

lib/ldclient-rb/impl/integrations/redis_impl.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ module Impl
66
module Integrations
77
module Redis
88
#
9-
# Internal implementation of the Redis feature store, intended to be used with CachingStoreWrapper.
9+
# Internal implementation of the Redis data store, intended to be used with CachingStoreWrapper.
1010
#
11-
class RedisFeatureStoreCore
11+
class RedisDataStoreCore
1212
begin
1313
require "redis"
1414
require "connection_pool"
@@ -19,7 +19,7 @@ class RedisFeatureStoreCore
1919

2020
def initialize(opts)
2121
if !REDIS_ENABLED
22-
raise RuntimeError.new("can't use Redis feature store because one of these gems is missing: redis, connection_pool")
22+
raise RuntimeError.new("can't use Redis data store because one of these gems is missing: redis, connection_pool")
2323
end
2424

2525
@redis_opts = opts[:redis_opts] || Hash.new
@@ -40,7 +40,7 @@ def initialize(opts)
4040
@stopped = Concurrent::AtomicBoolean.new(false)
4141

4242
with_connection do |redis|
43-
@logger.info("RedisFeatureStore: using Redis instance at #{redis.connection[:host]}:#{redis.connection[:port]} \
43+
@logger.info("RedisDataStore: using Redis instance at #{redis.connection[:host]}:#{redis.connection[:port]} \
4444
and prefix: #{@prefix}")
4545
end
4646
end
@@ -59,7 +59,7 @@ def init_internal(all_data)
5959
multi.set(inited_key, inited_key)
6060
end
6161
end
62-
@logger.info { "RedisFeatureStore: initialized with #{count} items" }
62+
@logger.info { "RedisDataStore: initialized with #{count} items" }
6363
end
6464

6565
def get_internal(kind, key)
@@ -95,13 +95,13 @@ def upsert_internal(kind, new_item)
9595
multi.hset(base_key, key, Model.serialize(kind, new_item))
9696
end
9797
if result.nil?
98-
@logger.debug { "RedisFeatureStore: concurrent modification detected, retrying" }
98+
@logger.debug { "RedisDataStore: concurrent modification detected, retrying" }
9999
try_again = true
100100
end
101101
else
102102
final_item = old_item
103103
action = new_item[:deleted] ? "delete" : "update"
104-
@logger.warn { "RedisFeatureStore: attempted to #{action} #{key} version: #{old_item[:version]} \
104+
@logger.warn { "RedisDataStore: attempted to #{action} #{key} version: #{old_item[:version]} \
105105
in '#{kind[:namespace]}' with a version that is the same or older: #{new_item[:version]}" }
106106
end
107107
redis.unwatch

lib/ldclient-rb/impl/store_client_wrapper.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
module LaunchDarkly
55
module Impl
66
#
7-
# Provides additional behavior that the client requires before or after feature store operations.
7+
# Provides additional behavior that the client requires before or after data store operations.
88
# Currently this just means sorting the data set for init(). In the future we may also use this
99
# to provide an update listener capability.
1010
#
11-
class FeatureStoreClientWrapper
12-
include Interfaces::FeatureStore
11+
class DataStoreClientWrapper
12+
include Interfaces::DataStore
1313

1414
def initialize(store)
1515
@store = store
1616
end
1717

1818
def init(all_data)
19-
@store.init(FeatureStoreDataSetSorter.sort_all_collections(all_data))
19+
@store.init(DataStoreDataSetSorter.sort_all_collections(all_data))
2020
end
2121

2222
def get(kind, key)

lib/ldclient-rb/impl/store_data_set_sorter.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
module LaunchDarkly
33
module Impl
44
#
5-
# Implements a dependency graph ordering for data to be stored in a feature store. We must use this
6-
# on every data set that will be passed to the feature store's init() method.
5+
# Implements a dependency graph ordering for data to be stored in a data store. We must use this
6+
# on every data set that will be passed to the data store's init() method.
77
#
8-
class FeatureStoreDataSetSorter
8+
class DataStoreDataSetSorter
99
#
1010
# Returns a copy of the input hash that has the following guarantees: the iteration order of the outer
1111
# hash will be in ascending order by the VersionDataKind's :priority property (if any), and for each

lib/ldclient-rb/in_memory_store.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
module LaunchDarkly
44

5-
# These constants denote the types of data that can be stored in the feature store. If
5+
# These constants denote the types of data that can be stored in the data store. If
66
# we add another storable data type in the future, as long as it follows the same pattern
77
# (having "key", "version", and "deleted" properties), we only need to add a corresponding
88
# constant here and the existing store should be able to handle it.
99
#
10-
# The :priority and :get_dependency_keys properties are used by FeatureStoreDataSetSorter
10+
# The :priority and :get_dependency_keys properties are used by DataStoreDataSetSorter
1111
# to ensure data consistency during non-atomic updates.
1212

1313
# @private
@@ -24,12 +24,12 @@ module LaunchDarkly
2424
}.freeze
2525

2626
#
27-
# Default implementation of the LaunchDarkly client's feature store, using an in-memory
27+
# Default implementation of the LaunchDarkly client's data store, using an in-memory
2828
# cache. This object holds feature flags and related data received from LaunchDarkly.
2929
# Database-backed implementations are available in {LaunchDarkly::Integrations}.
3030
#
31-
class InMemoryFeatureStore
32-
include LaunchDarkly::Interfaces::FeatureStore
31+
class InMemoryDataStore
32+
include LaunchDarkly::Interfaces::DataStore
3333

3434
def initialize
3535
@items = Hash.new

lib/ldclient-rb/integrations/consul.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module LaunchDarkly
55
module Integrations
66
module Consul
77
#
8-
# Default value for the `prefix` option for {new_feature_store}.
8+
# Default value for the `prefix` option for {new_data_store}.
99
#
1010
# @return [String] the default key prefix
1111
#
@@ -14,10 +14,10 @@ def self.default_prefix
1414
end
1515

1616
#
17-
# Creates a Consul-backed persistent feature store.
17+
# Creates a Consul-backed persistent data store.
1818
#
1919
# To use this method, you must first install the gem `diplomat`. Then, put the object returned by
20-
# this method into the `feature_store` property of your client configuration ({LaunchDarkly::Config}).
20+
# this method into the `data_store` property of your client configuration ({LaunchDarkly::Config}).
2121
#
2222
# @param opts [Hash] the configuration options
2323
# @option opts [Hash] :consul_config an instance of `Diplomat::Configuration` to replace the default
@@ -27,10 +27,10 @@ def self.default_prefix
2727
# @option opts [Logger] :logger a `Logger` instance; defaults to `Config.default_logger`
2828
# @option opts [Integer] :expiration (15) expiration time for the in-memory cache, in seconds; 0 for no local caching
2929
# @option opts [Integer] :capacity (1000) maximum number of items in the cache
30-
# @return [LaunchDarkly::Interfaces::FeatureStore] a feature store object
30+
# @return [LaunchDarkly::Interfaces::DataStore] a data store object
3131
#
32-
def self.new_feature_store(opts, &block)
33-
core = LaunchDarkly::Impl::Integrations::Consul::ConsulFeatureStoreCore.new(opts)
32+
def self.new_data_store(opts, &block)
33+
core = LaunchDarkly::Impl::Integrations::Consul::ConsulDataStoreCore.new(opts)
3434
return LaunchDarkly::Integrations::Util::CachingStoreWrapper.new(core, opts)
3535
end
3636
end

lib/ldclient-rb/integrations/dynamodb.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ module LaunchDarkly
55
module Integrations
66
module DynamoDB
77
#
8-
# Creates a DynamoDB-backed persistent feature store. For more details about how and why you can
9-
# use a persistent feature store, see the
8+
# Creates a DynamoDB-backed persistent data store. For more details about how and why you can
9+
# use a persistent data store, see the
1010
# [SDK reference guide](https://docs.launchdarkly.com/v2.0/docs/using-a-persistent-feature-store).
1111
#
1212
# To use this method, you must first install one of the AWS SDK gems: either `aws-sdk-dynamodb`, or
13-
# the full `aws-sdk`. Then, put the object returned by this method into the `feature_store` property
13+
# the full `aws-sdk`. Then, put the object returned by this method into the `data_store` property
1414
# of your client configuration ({LaunchDarkly::Config}).
1515
#
16-
# @example Configuring the feature store
17-
# store = LaunchDarkly::Integrations::DynamoDB::new_feature_store("my-table-name")
18-
# config = LaunchDarkly::Config.new(feature_store: store)
16+
# @example Configuring the data store
17+
# store = LaunchDarkly::Integrations::DynamoDB::new_data_store("my-table-name")
18+
# config = LaunchDarkly::Config.new(data_store: store)
1919
# client = LaunchDarkly::LDClient.new(my_sdk_key, config)
2020
#
2121
# Note that the specified table must already exist in DynamoDB. It must have a partition key called
@@ -31,15 +31,15 @@ module DynamoDB
3131
# @param table_name [String] name of an existing DynamoDB table
3232
# @param opts [Hash] the configuration options
3333
# @option opts [Hash] :dynamodb_opts options to pass to the DynamoDB client constructor (ignored if you specify `:existing_client`)
34-
# @option opts [Object] :existing_client an already-constructed DynamoDB client for the feature store to use
34+
# @option opts [Object] :existing_client an already-constructed DynamoDB client for the data store to use
3535
# @option opts [String] :prefix namespace prefix to add to all keys used by LaunchDarkly
3636
# @option opts [Logger] :logger a `Logger` instance; defaults to `Config.default_logger`
3737
# @option opts [Integer] :expiration (15) expiration time for the in-memory cache, in seconds; 0 for no local caching
3838
# @option opts [Integer] :capacity (1000) maximum number of items in the cache
39-
# @return [LaunchDarkly::Interfaces::FeatureStore] a feature store object
39+
# @return [LaunchDarkly::Interfaces::DataStore] a data store object
4040
#
41-
def self.new_feature_store(table_name, opts)
42-
core = LaunchDarkly::Impl::Integrations::DynamoDB::DynamoDBFeatureStoreCore.new(table_name, opts)
41+
def self.new_data_store(table_name, opts)
42+
core = LaunchDarkly::Impl::Integrations::DynamoDB::DynamoDBDataStoreCore.new(table_name, opts)
4343
return LaunchDarkly::Integrations::Util::CachingStoreWrapper.new(core, opts)
4444
end
4545
end

0 commit comments

Comments
 (0)