Sha256: 49192a7376716651d90e5d54a593ba5ba3594af9eeff7831b721d04a2ca17ebd

Contents?: true

Size: 570 Bytes

Versions: 9

Compression:

Stored size: 570 Bytes

Contents

require_relative '../lib/upperkut/worker'

class MyMiddleware
  def call(worker, items)
    logger = Upperkut::Logging.logger

    logger.info("performing worker=#{worker} items=#{items.count}")
    yield
    logger.info("performed worker=#{worker} items=#{items.count}")
  end
end

class WithMiddlewares
  include Upperkut::Worker

  setup_upperkut do |config|
    config.middlewares do |chain|
      chain.add MyMiddleware
    end
  end

  def perform(items)
    puts "executing........."
    exec_time = rand(80..200)
    sleep (exec_time.to_f / 1000.to_f)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
upperkut-0.5.1 examples/with_middlewares.rb
upperkut-0.5.0 examples/with_middlewares.rb
upperkut-0.4.6 examples/with_middlewares.rb
upperkut-0.4.5 examples/with_middlewares.rb
upperkut-0.4.4 examples/with_middlewares.rb
upperkut-0.4.3 examples/with_middlewares.rb
upperkut-0.4.2 examples/with_middlewares.rb
upperkut-0.4.1 examples/with_middlewares.rb
upperkut-0.4.0 examples/with_middlewares.rb