README.md in upperkut-0.7.1 vs README.md in upperkut-0.7.2

- old
+ new

@@ -21,12 +21,13 @@ Or install it yourself as: $ gem install upperkut ## Usage -Examples: +### Example 1 - Buffered Queue: + 1) Create a Worker class and the define how to process the batch; ```ruby class MyWorker include Upperkut::Worker @@ -34,11 +35,11 @@ setup_upperkut do |config| # Define which redis instance you want to use config.strategy = Upperkut::Strategies::BufferedQueue.new( self, - redis: { url: ENV['ANOTHER_REDIS_INSTANCE_URL']) }, + redis: { url: ENV['ANOTHER_REDIS_INSTANCE_URL'] }, batch_size: 400, # How many events should be dispatched to worker. max_wait: 300 # How long Processor wait in seconds to process batch. # even though the amount of items did not reached the # the batch_size. ) @@ -56,10 +57,57 @@ end ``` 2) Start pushings items; ```ruby - Myworker.push_items([{'id' => SecureRandom.uuid, 'name' => 'Robert C Hall', 'action' => 'EMAIL_OPENNED'}]) + Myworker.push_items( + [ + { + 'id' => SecureRandom.uuid, + 'name' => 'Robert C Hall', + 'action' => 'EMAIL_OPENNED' + } + ] + ) + ``` + +3) Start Upperkut; + ```bash + $ bundle exec upperkut --worker MyWorker --concurrency 10 + ``` + +### Example 2 - Scheduled Queue: + +1) Create a Worker class and the define how to process the batch; + ```ruby + require 'upperkut/strategies/scheduled_queue' + class MyWorker + include Upperkut::Worker + + setup_upperkut do |config| + config.strategy = Upperkut::Strategies::ScheduledQueue.new(self) + end + + def perform(batch_items) + heavy_processing(batch_items) + process_metrics(batch_items) + end + end + ``` + +2) Start pushings items with `timestamp` param; + ```ruby + # timestamp is 'Thu, 10 May 2019 23:43:58 GMT' + Myworker.push_items( + [ + { + 'timestamp' => '1557531838', + 'id' => SecureRandom.uuid, + 'name' => 'Robert C Hall', + 'action' => 'SEND_NOTIFICATION' + } + ] + ) ``` 3) Start Upperkut; ```bash $ bundle exec upperkut --worker MyWorker --concurrency 10