Sha256: 81f926662ac085c7b772711a416602c0aba6c4ed8f0b9b3cae2a8fea04692fdf

Contents?: true

Size: 1.06 KB

Versions: 13

Compression:

Stored size: 1.06 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], nil
            )
          end

          def cache_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

13 entries across 13 versions & 1 rubygems

Version Path
alephant-broker-3.6.1 lib/alephant/broker/load_strategy/s3/sequenced.rb
alephant-broker-3.6.0 lib/alephant/broker/load_strategy/s3/sequenced.rb
alephant-broker-3.5.5 lib/alephant/broker/load_strategy/s3/sequenced.rb
alephant-broker-3.5.4 lib/alephant/broker/load_strategy/s3/sequenced.rb
alephant-broker-3.5.3 lib/alephant/broker/load_strategy/s3/sequenced.rb
alephant-broker-3.5.2 lib/alephant/broker/load_strategy/s3/sequenced.rb
alephant-broker-3.5.1 lib/alephant/broker/load_strategy/s3/sequenced.rb
alephant-broker-3.5.0 lib/alephant/broker/load_strategy/s3/sequenced.rb
alephant-broker-3.4.1 lib/alephant/broker/load_strategy/s3/sequenced.rb
alephant-broker-3.4.0 lib/alephant/broker/load_strategy/s3/sequenced.rb
alephant-broker-3.3.2 lib/alephant/broker/load_strategy/s3/sequenced.rb
alephant-broker-3.3.1 lib/alephant/broker/load_strategy/s3/sequenced.rb
alephant-broker-3.3.0 lib/alephant/broker/load_strategy/s3/sequenced.rb