README.md in event_aggregator-1.0.1 vs README.md in event_aggregator-1.0.2
- old
+ new
@@ -1,7 +1,22 @@
# EventAggregator gem
+
+[![Gem Version](https://badge.fury.io/rb/event_aggregator.png)][gem]
+[![Build Status](https://travis-ci.org/stephan-nordnes-eriksen/event_aggregator.png?branch=adding_travis_and_other)][travis]
+[![Dependency Status](https://gemnasium.com/stephan-nordnes-eriksen/event_aggregator.png)][gemnasium]
+[![Code Climate](https://codeclimate.com/github/stephan-nordnes-eriksen/event_aggregator.png)][codeclimate]
+[![Coverage Status](https://coveralls.io/repos/stephan-nordnes-eriksen/event_aggregator/badge.png)][coveralls]
+[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/stephan-nordnes-eriksen/event_aggregator/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
+
+[gem]: https://rubygems.org/gems/event_aggregator
+[travis]: https://travis-ci.org/stephan-nordnes-eriksen/event_aggregator
+[gemnasium]: https://gemnasium.com/stephan-nordnes-eriksen/event_aggregator
+[codeclimate]: https://codeclimate.com/github/stephan-nordnes-eriksen/event_aggregator
+[coveralls]: https://coveralls.io/r/stephan-nordnes-eriksen/event_aggregator
+
+
The gem 'event_aggregator' is designed for use with the event aggregator pattern in Ruby.
## Installation
Add this line to your application's Gemfile:
@@ -24,11 +39,11 @@
require "event_aggregator"
class Foo
include EventAggregator::Listener
def initialize()
- message_type_register( "foo", lambda{|data| puts "bar" } )
+ message_type_register( "foo", lambda{|data| puts data } )
message_type_register( "foo2", method(:handle_message) )
end
def handle_message(data)
@@ -40,11 +55,11 @@
end
end
f = Foo.new
- EventAggregator::Message.new("foo", "data").publish
+ EventAggregator::Message.new("foo", "bar").publish
#=> bar
EventAggregator::Message.new("foo2", "data").publish
#=> data
EventAggregator::Message.new("foo3", "data").publish
#=> []
@@ -56,10 +71,28 @@
EventAggregator::Message.new("foo", "data").publish
EventAggregator::Message.new("foo", "data2").publish
#=> data2
#=> data
-Message.publish is asynchronous by default. To make it synchronous (not recommended) use the following:
+### IMPORTANT: Asynchronous by Default
+Message.publish is asynchronous by default. This means that if you run event_aggregator in a script that terminates, there is a chance that the script will terminate before the workers have processed the messages and you can receive an error looking like the following:
+
+ W, [2013-12-29T11:17:29.659902 #48097] WARN -- : Terminating task: type=:call, meta={:method_name=>:perform}, status=:callwait
+ D, [2013-12-29T11:17:29.660142 #48097] DEBUG -- : Celluloid::PoolManager: async call `perform` aborted!
+ Celluloid::Task::TerminatedError: task was terminated
+ /Users/user/.rvm/gems/ruby-1.9.3-p429/gems/celluloid-0.15.2/lib/celluloid/tasks/task_fiber.rb:32:in `terminate'
+ /Users/user/.rvm/gems/ruby-1.9.3-p429/gems/celluloid-0.15.2/lib/celluloid/actor.rb:404:in `block in cleanup'
+ /Users/user/.rvm/gems/ruby-1.9.3-p429/gems/celluloid-0.15.2/lib/celluloid/actor.rb:404:in `each'
+ /Users/user/.rvm/gems/ruby-1.9.3-p429/gems/celluloid-0.15.2/lib/celluloid/actor.rb:404:in `cleanup'
+ /Users/user/.rvm/gems/ruby-1.9.3-p429/gems/celluloid-0.15.2/lib/celluloid/actor.rb:375:in `shutdown'
+ /Users/user/.rvm/gems/ruby-1.9.3-p429/gems/celluloid-0.15.2/lib/celluloid/actor.rb:185:in `run'
+ /Users/user/.rvm/gems/ruby-1.9.3-p429/gems/celluloid-0.15.2/lib/celluloid/actor.rb:157:in `block in initialize'
+ /Users/user/.rvm/gems/ruby-1.9.3-p429/gems/celluloid-0.15.2/lib/celluloid/thread_handle.rb:13:in `block in initialize'
+ /Users/user/.rvm/gems/ruby-1.9.3-p429/gems/celluloid-0.15.2/lib/celluloid/internal_pool.rb:100:in `call'
+ /Users/user/.rvm/gems/ruby-1.9.3-p429/gems/celluloid-0.15.2/lib/celluloid/internal_pool.rb:100:in `block in create'
+ W, [2013-12-29T11:17:29.660271 #48097] WARN -- : Terminating task: type=:finalizer, meta={:method_name=>:__shutdown__}, status=:callwait
+
+To make it synchronous (not recommended) use the following:
EventAggregator::Message.new("foo", "data", false).publish
#=> data
The message data is duplicated by default for each of the receiving listeners. To force the same object for all listeners, set the consisten_data property to true.