Sha256: a722673148ff611d00ef6a22949e3505ae517d6d1a557298f8bd57facc489ab1
Contents?: true
Size: 1.83 KB
Versions: 1
Compression:
Stored size: 1.83 KB
Contents
require_relative 'upperkut/version' require_relative 'upperkut/worker' require 'redis' # Public: Upperkut is a batch background processing tool for Ruby. # # Examples: # # 1) Create a Worker class and the define how to process the batch; # # class MyWorker # include Upperkut::Worker # # # This is optional # # setup_upperkut do |s| # # Define which redis instance you want to use # s.redis = Redis.new(url: ENV['ANOTHER_REDIS_INSTANCE_URL']) # # # Define the amount of items must be accumulated # s.batch_size = 2_000 # The default value is 1_000 # # # How frequent the Processor should hit redis looking for elegible # # batch. The default value is 5. You can also set the env # # UPPERKUT_POLLING_INTERVAL. # s.polling_interval = 4 # # # How long the Processor should wait to process batch even though # # the amount of items did not reached the batch_size. # s.max_wait = 300 # end # # def perform(batch_items) # SidekiqJobA.perform_async(batch_items) # SidekiqJobB.perform_async(batch_items) # # process_metrics(batch_items) # end # end # # 2) Start pushings items; # # Myworker.push([{'id' => SecureRandom.uuid}, 'name' => 'Robert C Hall', 'action' => 'EMAIL_OPENNED']) # # 3) Start Upperkut; # # $ bundle exec upperkut -worker MyWorker --concurrency 10 # # 4) That's it :) module Upperkut class Configuration attr_accessor :batch_size, :redis, :strategy, :max_wait, :polling_interval def self.default new.tap do |config| config.batch_size = 1_000 config.redis = Redis.new config.max_wait = Integer(ENV['UPPERKUT_MAX_WAIT'] || 20) config.polling_interval = Integer(ENV['UPPERKUT_POLLING_INTERVAL'] || 5) end end end class Shutdown < StandardError ; end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
upperkut-0.1.2 | lib/upperkut.rb |