Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kostya/sidekiq-kawai
Syntax sugar for Sidekiq consumers. Each consumer is a class, with clean interface, and custom logger.
https://github.com/kostya/sidekiq-kawai
Last synced: 20 days ago
JSON representation
Syntax sugar for Sidekiq consumers. Each consumer is a class, with clean interface, and custom logger.
- Host: GitHub
- URL: https://github.com/kostya/sidekiq-kawai
- Owner: kostya
- License: mit
- Created: 2012-07-29T18:31:05.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2015-03-02T17:15:39.000Z (over 9 years ago)
- Last Synced: 2024-09-21T23:50:51.827Z (about 2 months ago)
- Language: Ruby
- Homepage:
- Size: 179 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Sidekiq Kawai
============Syntax sugar for Sidekiq consumers. Each consumer is a class, with clean interface, and custom logger.
Usefull when count of different events ~100 and more.``` ruby
gem 'sidekiq-kawai'
```rails generate sk:add bla
Consumer
--------
app/workers/sk_bla.rb``` ruby
class SkBla < SkQueuedef some_method1(a, b, c)
logger.info "async called some_method1 with #{[a, b, c].inspect}"
enddef some_method2(x)
logger.info "async called some_method2 with #{x.inspect}"
endend
```Insert event into queue like this:
SkBla.some_method1(1, 2, 3)
or
SkBla.add_event(:some_method2, some_x)
Logger for this consumer: Rails.root/log/workers/bla.log
### Options
``` ruby
class SkBla < SkQueue# specify custom logger
sidekiq_options :logger_path => "#{Rails.root}/log/bla.log"# enables benchmark for each event (into logger)
sidekiq_options :benchmark => true# don't notify logger about failed events
sidekiq_options :alerts => falseend
```### Proxy method to consumer
Usefull in specs``` ruby
SkBla.proxy(:some_method1)
```When code call SkBla.some_method1(a,b,c) this would be convert into SkBla.new.some_method1(a,b,c)
### Insert events with scheduler
``` ruby
SkBla.add_event_in(10.seconds, :some_method1, 1, 2, 3)SkBla.enqueue_in(10.seconds, :some_method1, 1, 2, 3)
SkBla.some_method2_in(2.minutes.from_now, "call instance method on Worker sheduled async")
SkBla.some_method2_at(2.minutes.from_now, "call instance method on Worker sheduled async")
```