Actor system with amqp or in memory queues as backend. Provides an easy to use DSL and a high level abstraction to the AMQP protocol.
class MyActor < AmqpActors::Actor
act do |msg|
puts msg
end
end
AmqpActors.Sytem.start
MyActor.push 'hello'
Act (required). Message processor
act do |msg|
...
end
Typed messages. Built in type checking of messages.
message_type Numeric
message_type Array => String
message_type Set => Object
Concurrency. Define number of threads for an actor.
thread_count 10
Helpers. Define helper methods for your actor.
helpers do
def do_stuff
...
end
end
Inbox size. Check number of enqueued messages.
inbox_size # => 0
Destory actor. Closes inbox and kills all actor threads for current actor.
die
Messages are sent by using an actors class method push
Start. Start the actor system.
AmqpActors.System.start
Stop. Stops the system.
AmqpActors.System.stop
Subclass AmqpActors::TestActor
in tests. It uses an in memory queue as backed by default and provides an extra method for passing values out of the actor. This can then be read syncronously in the test.
class TestActor < AmqpActors::TestActor
act do |msg|
output msg + 1
end
end
..
TestActor.push 0
TestActor.output # => 1