GitXplorerGitXplorer
k

sidekiq-hostname_fetch

public
6 stars
4 forks
0 issues

Commits

List of commits on branch master.
Unverified
ff31dab446bee92a8b0d6c73dc9e7851b6dc75ad

Docs for perform_async_on_current_host

kkirs committed 11 years ago
Unverified
bd78400144951bdb13074f83498ea5559bc377fa

for_host => on_host

kkirs committed 12 years ago
Unverified
4d5381a04e8ddf726032bc5b58b9c59ad58cd9ee

perform_async_on_current_host method + spec

kkirs committed 12 years ago
Unverified
1d33b898df5405980cb08731ee5601121feb834a

Build status in readme

kkirs committed 12 years ago
Unverified
e2171a8bc852127914d0ee85d72044c8681eef5b

Travis config

kkirs committed 12 years ago
Unverified
b3bec0499d2f0bcc78b12a53f979ef86570ca931

Strategy specs

kkirs committed 12 years ago

README

The README file for this repository.

Sidekiq::HostnameFetch Strategy

Build Status

Imagine: you have 10 sidekiq job servers and you want to enque some job on specific server. With this strategy you can easily do this.

Sponsored by Evil Martians.

Thanks to Yaroslav Markin and Alexey Gaziev for advice about making this project.

Installation

Add this line to your application's Gemfile:

gem 'sidekiq-hostname_fetch', github: "kirs/sidekiq-hostname_fetch"

And then execute:

$ bundle

Usage

Define the hostname strategy:

Sidekiq.configure_server do |config|
  config.options[:fetch] = Sidekiq::HostnameFetch::Strategy
end

Now Sidekiq server will fetch tasks also from hostname-specific queues.

To send jobs to specific server, you can use:

MyWorker.perform_async_on_host "app-03.beta.myproject.com", "arg_to_worker", "another_arg"

As well as perform_in_on_host and perform_at_on_host.

Another way is to declate sidekiq_options host_specific: true inside the worker. With this option, task will be always performed on the same server it was enqueed.

To perform only one job on current host, use perform_async_on_current_host.

Simple demo

(you can pick up demo.rb from this repo)

Start up sidekiq via

bundle exec sidekiq -r ./demo.rb

and then you can open up an IRB session like so:

bundle exec irb -r ./demo.rb

where you can then say

HardWorker.perform_async # <-- without plugin
HardWorker.perform_async_on_host "myhost" # <-- won't work
HardWorker.perform_async_on_host `hostname`.strip # <-- gonna work on your machine

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request