Class: LaunchDarkly::Impl::Integrations::DynamoDB::DynamoDBBigSegmentStore
- Inherits:
-
DynamoDBStoreImplBase
- Object
- DynamoDBStoreImplBase
- LaunchDarkly::Impl::Integrations::DynamoDB::DynamoDBBigSegmentStore
- Defined in:
- lib/ldclient-rb/impl/integrations/dynamodb_impl.rb
Overview
Constant Summary collapse
- KEY_METADATA =
'big_segments_metadata'
- KEY_CONTEXT_DATA =
'big_segments_user'
- ATTR_SYNC_TIME =
'synchronizedOn'
- ATTR_INCLUDED =
'included'
- ATTR_EXCLUDED =
'excluded'
Instance Method Summary collapse
- #description ⇒ Object
- #get_membership(context_hash) ⇒ Object
- #get_metadata ⇒ Object
-
#initialize(table_name, opts) ⇒ DynamoDBBigSegmentStore
constructor
A new instance of DynamoDBBigSegmentStore.
Constructor Details
#initialize(table_name, opts) ⇒ DynamoDBBigSegmentStore
Returns a new instance of DynamoDBBigSegmentStore.
240 241 242 |
# File 'lib/ldclient-rb/impl/integrations/dynamodb_impl.rb', line 240 def initialize(table_name, opts) super(table_name, opts) end |
Instance Method Details
#description ⇒ Object
244 245 246 |
# File 'lib/ldclient-rb/impl/integrations/dynamodb_impl.rb', line 244 def description "DynamoDBBigSegmentStore" end |
#get_membership(context_hash) ⇒ Object
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/ldclient-rb/impl/integrations/dynamodb_impl.rb', line 262 def get_membership(context_hash) data = @client.get_item( table_name: @table_name, key: { PARTITION_KEY => @prefix + KEY_CONTEXT_DATA, SORT_KEY => context_hash, }) return nil unless data.item excluded_refs = data.item[ATTR_EXCLUDED] || [] included_refs = data.item[ATTR_INCLUDED] || [] if excluded_refs.empty? && included_refs.empty? nil else membership = {} excluded_refs.each { |ref| membership[ref] = false } included_refs.each { |ref| membership[ref] = true } membership end end |
#get_metadata ⇒ Object
248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/ldclient-rb/impl/integrations/dynamodb_impl.rb', line 248 def key = @prefix + KEY_METADATA data = @client.get_item( table_name: @table_name, key: { PARTITION_KEY => key, SORT_KEY => key, } ) = data.item && data.item[ATTR_SYNC_TIME] ? data.item[ATTR_SYNC_TIME] : nil LaunchDarkly::Interfaces::BigSegmentStoreMetadata.new() end |