Sha256: cc0c72b172b6a11c870de18b1fe525d7095ad439a89c9ee69547ba15b142c467

Contents?: true

Size: 1.13 KB

Versions: 10

Compression:

Stored size: 1.13 KB

Contents

require "alephant/broker/load_strategy/s3/base"

module Alephant
  module Broker
    module LoadStrategy
      module S3
        class Sequenced < Base
          def sequence(component_meta)
            sequencer.get_last_seen component_meta.key
          end

          def s3_path(component_meta)
            lookup.read(
              component_meta.id,
              component_meta.options,
              sequence(component_meta)
            ).tap do |obj|
              fail InvalidCacheKey if obj.location.nil?
            end.location unless sequence(component_meta).nil?
          end

          def sequencer
            @sequencer ||= Alephant::Sequencer.create(
              Broker.config[:sequencer_table_name],
              {
                :config => Broker.config
              }
            )
          end

          def storage_key(component_meta)
            "#{super(component_meta)}/#{sequence(component_meta)}"
          end

          def headers(component_meta)
            {
              "X-Sequence" => sequence(component_meta).to_s
            }.merge(super(component_meta))
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
alephant-broker-3.13.0 lib/alephant/broker/load_strategy/s3/sequenced.rb
alephant-broker-3.12.0 lib/alephant/broker/load_strategy/s3/sequenced.rb
alephant-broker-3.11.0 lib/alephant/broker/load_strategy/s3/sequenced.rb
alephant-broker-3.10.2 lib/alephant/broker/load_strategy/s3/sequenced.rb
alephant-broker-3.10.1 lib/alephant/broker/load_strategy/s3/sequenced.rb
alephant-broker-3.10.0 lib/alephant/broker/load_strategy/s3/sequenced.rb
alephant-broker-3.9.2 lib/alephant/broker/load_strategy/s3/sequenced.rb
alephant-broker-3.9.1 lib/alephant/broker/load_strategy/s3/sequenced.rb
alephant-broker-3.9.0 lib/alephant/broker/load_strategy/s3/sequenced.rb
alephant-broker-3.8.0 lib/alephant/broker/load_strategy/s3/sequenced.rb