Class: LaunchDarkly::Impl::Integrations::DynamoDB::DynamoDBBigSegmentStore

Inherits:
DynamoDBStoreImplBase show all
Defined in:
lib/ldclient-rb/impl/integrations/dynamodb_impl.rb

Overview

Since:

  • 5.5.0

Constant Summary collapse

KEY_METADATA =

Since:

  • 5.5.0

'big_segments_metadata'
KEY_CONTEXT_DATA =

Since:

  • 5.5.0

'big_segments_user'
ATTR_SYNC_TIME =

Since:

  • 5.5.0

'synchronizedOn'
ATTR_INCLUDED =

Since:

  • 5.5.0

'included'
ATTR_EXCLUDED =

Since:

  • 5.5.0

'excluded'

Constants inherited from DynamoDBStoreImplBase

LaunchDarkly::Impl::Integrations::DynamoDB::DynamoDBStoreImplBase::PARTITION_KEY, LaunchDarkly::Impl::Integrations::DynamoDB::DynamoDBStoreImplBase::SORT_KEY

Instance Method Summary collapse

Methods inherited from DynamoDBStoreImplBase

#stop

Constructor Details

#initialize(table_name, opts) ⇒ DynamoDBBigSegmentStore

Returns a new instance of DynamoDBBigSegmentStore.

Since:

  • 5.5.0



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

#descriptionObject

Since:

  • 5.5.0



244
245
246
# File 'lib/ldclient-rb/impl/integrations/dynamodb_impl.rb', line 244

def description
  "DynamoDBBigSegmentStore"
end

#get_membership(context_hash) ⇒ Object

Since:

  • 5.5.0



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_metadataObject

Since:

  • 5.5.0



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,
    }
  )
  timestamp = data.item && data.item[ATTR_SYNC_TIME] ?
    data.item[ATTR_SYNC_TIME] : nil
  LaunchDarkly::Interfaces::BigSegmentStoreMetadata.new(timestamp)
end