README.md in rocketman-0.1.0 vs README.md in rocketman-0.1.1
- old
+ new
@@ -25,11 +25,11 @@
$ gem install rocketman
## Usage
-Rocketman exposes two module, `Rocketman::Producer` and `Rocketman::Consumer`. They do exactly as what their name implies. All you need to do is `include` them into your code.
+Rocketman exposes two module, `Rocketman::Producer` and `Rocketman::Consumer`. They do exactly as what their name implies. All you need to do is `include Rocketman::Producer` and `extend Rocketman::Consumer` into your code.
#### Producer
Producer exposes one **instance** method to you: `:emit`. `:emit` takes in the event name and an optional payload and publishes it to the consumers. There's nothing more you need to do. The producer do not have to know who its consumers are.
```ruby
@@ -40,15 +40,26 @@
emit :hello, payload: {"one" => 1, "two" => 2}
end
end
```
+Note that Producer emit events with threads that run in a thread pool. The default number of worker is 5, and the workers default to checking the job with a 3 seconds interval. You can tweak it to your liking like so:
+
+```ruby
+# config/initializers/rocketman.rb
+
+Rocketman.configure do |config|
+ config.worker_count = 10 # defaults to 5
+ config.latency = 1 # defaults to 3, unit is :seconds
+end
+```
+
#### Consumer
Consumer exposes a **class** method, `:on_event`. `:on_event` takes in the event name, and also an additional block, which gets executed whenever a message is received. If an additional `payload` is emitted along with the event, you can get access to it in the form of block argument.
```ruby
class Consumer
- include Rocketman::Consumer
+ extend Rocketman::Consumer
on_event :hello do |payload|
puts "I've received #{payload} here!"
# => I've received {:payload=>{"one"=>1, "two"=>2}} here!
end