README.md in dispatch-rider-1.4.2 vs README.md in dispatch-rider-1.5.0
- old
+ new
@@ -228,21 +228,119 @@
* `logger` : what logger to use to send messages to (responds to the standard ruby Logger protocol), defaults to a new Logger sending messages to STDERR
### Callbacks
-Dispatch rider supports injecting callbacks in a few parts of the
-lifecycle of the process.
+Dispatch rider supports injecting callbacks in a few parts of the lifecycle of the process. Each
+callback can have hooks plugged into it at `before`, `after` and `around` the execution.
+#### On initialize `:initialize`
+
+This callback is called when the runner is being initialized.
+
+Block Arguments:
+
+* _None_
+
+
+```ruby
+DispatchRider.config do |config|
+ config.before(:initialize) do
+ # your code here
+ end
+
+ config.around(:initialize) do |job|
+ # your code here
+ job.call
+ # your code here
+ end
+
+ config.after(:initialize) do
+ # your code here
+ end
+end
```
- :initialize - when the runner is being initialized
- :process - when the runner is running its event loop
- :dispatch_message - around the execution of a single message (the block is passed the job )
+
+#### On publish `:publish`
+
+This callback is called when the message is being published.
+
+Block Arguments:
+
+* message: `[DispatchRider::Message]` -- message that is about to be sent
+* destinations: `[Array<Symbol>]` -- list of destinations to sent to
+
+```ruby
+DispatchRider.config do |config|
+ config.before(:publish) do |message:, destinations:|
+ # your code here
+ end
+
+ config.around(:publish) do |job, message:, destinations:|
+ # your code here
+ job.call
+ # your code here
+ end
+
+ config.after(:publish) do |message:, destinations:|
+ # your code here
+ end
+end
```
-Each callback can have hooks plugged into it at `before`, `after` and `around` the execution.
+#### On process `:process`
+This callback is called when the runner is running its event loop.
+
+Block Arguments:
+
+* _None_
+
+```ruby
+DispatchRider.config do |config|
+ config.before(:process) do
+ # your code here
+ end
+
+ config.around(:process) do |job|
+ # your code here
+ job.call
+ # your code here
+ end
+
+ config.after(:process) do
+ # your code here
+ end
+end
+```
+
+#### On dispatch message `:dispatch_message`
+
+This callback is called when executing a single message.
+
+Block Arguments:
+
+* message `[DispatchRider::Message]` -- the message received from `DispatchRider` queue
+
+```ruby
+DispatchRider.config do |config|
+ config.before(:dispatch_message) do |message|
+ # your code here
+ end
+
+ config.around(:dispatch_message) do |job, message|
+ # your code here
+ job.call
+ # your code here
+ end
+
+ config.after(:dispatch_message) do |message|
+ # your code here
+ end
+end
+```
+
### Manual Setup
To setup a subscriber you'll need message handlers. The handlers are named the same as the message subjects.
Each handler may also specify a retry_timeout as shown below. When a job throws an exception it will be put back
on the queue in that time period if the queue supports timeouts. If the underlying queue (such as filesystem) does
@@ -362,17 +460,17 @@
```bash
vim lib/dispatch-rider/version.rb
# set the new version
-rake gemspec
-# commit any changed files (should be only version and the gemspec)
+# commit the changed version file
# name your commit with the version number eg: "1.8.0"
rake release
# to push the gem to rubygems.org
rake changelog
# commit the changed changelog
# name your commit with the version again eg: "changelog for 1.8.0"
+git push
```
## Contributing
### Process