Skip to content

84codes/amqp-actors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Code Climate Test Coverage

AmqpActors

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.

Hello World

class MyActor < AmqpActors::Actor
  act do |msg|
    puts msg
  end
end

AmqpActors.Sytem.start
MyActor.push 'hello'

Actor DSL

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

Message passing

Messages are sent by using an actors class method push

System module

Start. Start the actor system.

AmqpActors.System.start

Stop. Stops the system.

AmqpActors.System.stop

Testing

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

About

Ruby actors on top of AMQP

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages