Sha256: ddf3d1d736c9ec01d824b4d14e9a54fe9d7ebc7a5efbeef0e3c0573488a67455

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

require "aws-sdk"
require "thread"
require "timeout"

require "alephant/support/dynamodb/table"
require "alephant/logger"

module Alephant
  module Lookup
    class LookupTable < ::Alephant::Support::DynamoDB::Table
      include Logger
      attr_reader :table_name, :client

      def initialize(table_name)
        @mutex      = Mutex.new
        @client     = AWS::DynamoDB::Client::V20120810.new
        @table_name = table_name
        logger.info(
          "event"     => "LookupTableInitialized",
          "tableName" => table_name,
          "method"    => "#{self.class}#initialize"
        )
      end

      def write(component_key, version, location)
        client.put_item({
          :table_name => table_name,
          :item => {
            'component_key' => {
              'S' => component_key.to_s
            },
            'batch_version' => {
              'N' => version.to_s
            },
            'location' => {
              'S' => location.to_s
            }
          }
        }).tap do
          logger.info(
            "event"        => "LookupLocationWritten",
            "componentKey" => component_key,
            "version"      => version,
            "location"     => location,
            "method"       => "#{self.class}#write"
          )
        end
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alephant-lookup-2.0.2 lib/alephant/lookup/lookup_table.rb
alephant-lookup-2.0.1 lib/alephant/lookup/lookup_table.rb
alephant-lookup-2.0.0 lib/alephant/lookup/lookup_table.rb
alephant-lookup-1.0.0 lib/alephant/lookup/lookup_table.rb