Sha256: 48200573c2047d89f9a54f049e06941ac99e66dd167e14e4f3d6095e2a1f4f1d
Contents?: true
Size: 1004 Bytes
Versions: 8
Compression:
Stored size: 1004 Bytes
Contents
module DCell # Manage nodes we're connected to class NodeManager include Celluloid::ZMQ include Enumerable attr_reader :heartbeat_rate, :heartbeat_timeout def initialize @nodes = {} @heartbeat_rate = 5 # How often to send heartbeats in seconds @heartbeat_timeout = 10 # How soon until a lost heartbeat triggers a node partition end # Return all available nodes in the cluster def all Directory.all.map do |node_id| find node_id end end # Iterate across all available nodes def each Directory.all.each do |node_id| yield find node_id end end # Find a node by its node ID def find(id) node = @nodes[id] return node if node addr = Directory[id] return unless addr if id == DCell.id node = DCell.me else node = Node.new(id, addr) end @nodes[id] ||= node @nodes[id] end alias_method :[], :find end end
Version data entries
8 entries across 8 versions & 1 rubygems