Sha256: 9d1e1bcded71266127a1492495ab0eb52f74bc3b40a06d8eb9ddf6db6fc39f98

Contents?: true

Size: 806 Bytes

Versions: 2

Compression:

Stored size: 806 Bytes

Contents

module DCell
  class FutureProxy
    def initialize(mailbox_id,node_id,node_addr)
      @mailbox_id = mailbox_id
      @node_id = node_id
      @node_addr = node_addr
    end

    def <<(message)
      node = Node[@node_id]
      node = Node.new(@node_id, @node_addr) unless node
      node.send_message! Message::Relay.new(self, message)
    end

    def _dump(level)
      "#{@mailbox_id}@#{@node_id}@#{@node_addr}"
    end

    # Loader for custom marshal format
    def self._load(string)
      mailbox_id, node_id, node_addr = string.split("@")

      if node_id == DCell.id
        future = Router.find(mailbox_id)
        raise "tried to unmarshal dead Celluloid::Future: #{mailbox_id}" unless future
        future
      else
        new(mailbox_id, node_id, node_addr)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dcell-0.12.0.pre lib/dcell/future_proxy.rb
dcell-0.10.0 lib/dcell/future_proxy.rb