Sha256: d500af292d4aa10f1486b5771daedec48bde0ebaa086f21f1bb773cd74b2f22e

Contents?: true

Size: 944 Bytes

Versions: 2

Compression:

Stored size: 944 Bytes

Contents

require 'forwardable'
require 'upperkut/strategies/buffered_queue'
require 'upperkut/middleware'
require 'upperkut/util'
require 'upperkut'

module Upperkut
  module Worker
    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods
      extend Forwardable

      def_delegators :setup, :strategy, :server_middlewares, :client_middlewares
      def_delegators :strategy, :metrics, :clear

      def push_items(items)
        client_middlewares.invoke(self, items) do
          strategy.push_items(items)
        end
      end

      def fetch_items
        strategy.fetch_items
      end

      def setup_upperkut
        yield(setup) if block_given?
      end

      def setup
        @config ||=
          begin
            config = Upperkut::Configuration.default.clone
            config.strategy = Upperkut::Strategies::BufferedQueue.new(self)
            config
          end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
upperkut-0.7.1 lib/upperkut/worker.rb
upperkut-0.7.0 lib/upperkut/worker.rb