README.md in message_bus-2.0.1 vs README.md in message_bus-2.0.2
- old
+ new
@@ -81,10 +81,16 @@
MessageBus.configure(group_ids_lookup: proc do |env|
# return the group ids the user belongs to
# can be nil or []
end)
+MessageBus.configure(on_middleware_error: proc do |env, e|
+ # If you wish to add special handling based on error
+ # return a rack result array: [status, headers, body]
+ # If you just want to pass it on return nil
+end)
+
# example of message bus to set user_ids from an initializer in Rails and Devise:
# config/inializers/message_bus.rb
MessageBus.user_id_lookup do |env|
req = Rack::Request.new(env)
if req.session && req.session["warden.user.user.key"] && req.session["warden.user.user.key"][0][0]
@@ -210,12 +216,14 @@
`MessageBus.stop()` : Stop all MessageBus activity
`MessageBus.start()` : Must be called to startup the MessageBus poller
-`MessageBus.subscribe(channel,func,lastId)` : Subscribe to a channel, optionally you may specify the id of the last message you received in the channel.
+`MessageBus.status()` : Return status (started, paused, stopped)
+`MessageBus.subscribe(channel,func,lastId)` : Subscribe to a channel, optionally you may specify the id of the last message you received in the channel. The callback accepts three arguments: `func(payload, globalId, messageId)`. You may save globalId or messageId of received messages and use then at a later time when client needs to subscribe, receiving the backlog just after that Id.
+
`MessageBus.unsubscribe(channel,func)` : Unsubscribe callback from a particular channel
`MessageBus.noConflict()` : Removes MessageBus from the global namespace by replacing it with whatever was present before MessageBus was loaded. Returns a reference to the MessageBus object.
## Running tests
@@ -297,10 +305,10 @@
For more information see [Passenger documentation](https://www.phusionpassenger.com/library/config/nginx/tuning_sse_and_websockets/)
#### Puma
```ruby
# path/to/your/config/puma.rb
-require 'message_bus'
+require 'message_bus' # omit this line for Rails 5
on_worker_boot do
MessageBus.after_fork
end
```