Sha256: 033fd4b81e3a559a9d67aa9c34662883527812ae27edb14cd3dbd524a9811f88
Contents?: true
Size: 945 Bytes
Versions: 3
Compression:
Stored size: 945 Bytes
Contents
require_relative '../lib/upperkut/worker' require_relative '../lib/upperkut/logging' class ClientMiddleware def call(worker, items) logger = Upperkut::Logging.logger logger.info("inserting worker=#{worker} items=#{items.count}") yield logger.info("inserted worker=#{worker} items=#{items.count}") end end 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.server_middlewares do |chain| chain.add MyMiddleware end config.client_middlewares do |chain| chain.add ClientMiddleware 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
upperkut-0.7.0 | examples/with_middlewares.rb |
upperkut-0.6.0 | examples/with_middlewares.rb |
upperkut-0.5.2 | examples/with_middlewares.rb |