class Alephant::Lookup::LookupTable

Attributes

client[R]
table_name[R]

Public Class Methods

new(table_name) click to toggle source
# File lib/alephant/lookup/lookup_table.rb, line 14
def initialize(table_name)
  options = {}
  options.merge!({endpoint: ENV['AWS_DYNAMO_DB_ENDPOINT']}) if ENV['AWS_DYNAMO_DB_ENDPOINT']
  @mutex      = Mutex.new
  @client     = Aws::DynamoDB::Client.new(options)
  @table_name = table_name
  logger.info(
    "event"     => "LookupTableInitialized",
    "tableName" => table_name,
    "method"    => "#{self.class}#initialize"
  )
end

Public Instance Methods

write(component_key, version, location) click to toggle source
# File lib/alephant/lookup/lookup_table.rb, line 27
def write(component_key, version, location)
  client.put_item({
    table_name: table_name,
    item: {
      'component_key' => component_key.to_s,
      'batch_version' => version,
      'location'      => location.to_s
    }
  }).tap do
    logger.info(
      "event"        => "LookupLocationWritten",
      "componentKey" => component_key,
      "version"      => version,
      "location"     => location,
      "method"       => "#{self.class}#write"
    )
  end
end