Sha256: ecdc39ef4c032ef2063a35899f32688521f28b53021b1600b8992de49d913819
Contents?: true
Size: 688 Bytes
Versions: 1
Compression:
Stored size: 688 Bytes
Contents
require 'cellect/node_set' require 'socket' module Cellect module Server class NodeSet < Cellect::NodeSet attr_accessor :id protected # Registers this server instance with ZooKeeper def setup zk.mkdir_p '/nodes' # Find the local ipv4 address address = Socket.ip_address_list.find{ |address| address.ipv4? && !address.ipv4_loopback? } raise "Cannot identify IP address" unless address # Register this instance with an autoincrementing id path = zk.create '/nodes/node', data: address.ip_address, mode: :ephemeral_sequential self.id = path.sub /^\/nodes\//, '' end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cellect-server-0.1.3 | lib/cellect/server/node_set.rb |