Sha256: 2d182513bb45cee09506b6aa44e5c272d732291efbe8157c9b06719323ea7da6
Contents?: true
Size: 1.68 KB
Versions: 3
Compression:
Stored size: 1.68 KB
Contents
module DCell class Message attr_reader :id def initialize # Memoize the original object ID so it will get marshalled # Perhaps this should use a real UUID scheme @id = object_id end # Heartbeat messages inform other nodes this node is healthy class Heartbeat < Message def initialize @id = DCell.id end def dispatch node = DCell::Node[@id] node.handle_heartbeat if node end end # Query a node for the address of an actor class Find < Message attr_reader :caller, :name def initialize(caller, name) super() @caller, @name = caller, name end def dispatch @caller << SuccessResponse.new(@id, Celluloid::Actor[@name]) end end # List all registered actors class List < Message attr_reader :caller def initialize(caller) super() @caller = caller end def dispatch @caller << SuccessResponse.new(@id, Celluloid::Actor.registered) end end # Relay a message to the given recipient class Relay < Message attr_reader :recipient, :message def initialize(recipient, message) super() @recipient, @message = recipient, message end def dispatch DCell::Router.route @recipient, @message end end # Send a system event to the given recipient class SystemEvent < Message attr_reader :recipient, :event def initialize(recipient, event) super() @recipient, @event = recipient, event end def dispatch DCell::Router.route_system_event @recipient, @event end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dcell-0.9.0 | lib/dcell/messages.rb |
dcell-0.8.0 | lib/dcell/messages.rb |
dcell-0.7.1 | lib/dcell/messages.rb |