Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kostya/resque-kawai
Syntax sugar for Resque consumers. Each consumer is a class, with clean interface, and custom logger.
https://github.com/kostya/resque-kawai
Last synced: 20 days ago
JSON representation
Syntax sugar for Resque consumers. Each consumer is a class, with clean interface, and custom logger.
- Host: GitHub
- URL: https://github.com/kostya/resque-kawai
- Owner: kostya
- License: mit
- Created: 2012-04-21T22:55:17.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-12-24T16:09:35.000Z (almost 12 years ago)
- Last Synced: 2024-09-25T19:40:19.043Z (about 2 months ago)
- Language: Ruby
- Homepage:
- Size: 187 KB
- Stars: 3
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Resque Kawai
============Syntax sugar for Resque consumers. Each consumer is a class, with clean interface, and custom logger.
Usefull when count of different events ~100 and more.``` ruby
gem 'resque-kawai'
```rails generate rq:add bla
Consumer
--------
app/workers/rq_bla.rb``` ruby
class RqBla < RqQueuedef some_method1(a, b, c)
logger.info "async called some_method1 with #{[a, b, c].inspect}"
end
def some_method2(x)
logger.info "async called some_method2 with #{x.inspect}"
end
end
```Insert event into queue like this:
RqBla.some_method1(1, 2, 3)
or
RqBla.add_event(:some_method2, some_x)
Logger for this consumer: Rails.root/log/workers/bla.log
### Options``` ruby
class RqBla < RqQueue# specify custom logger
self.logger_path = "#{Rails.root}/log/bla.log"
# enables benchmark for each event (into logger)
self.benchmark = true
end
```### Proxy method to consumer
Usefull in specs``` ruby
RqBla.proxy(:some_method1)
```When code call RqBla.some_method1(a,b,c) this would be convert into RqBla.new.some_method1(a,b,c)
### Insert event with Resque-scheduler
``` ruby
RqBla.add_event_in(10.seconds, :some_method1, 1, 2, 3)
RqBla.enqueue_in(10.seconds, :some_method1, 1, 2, 3)
```