lib/dcell.rb in dcell-0.10.0 vs lib/dcell.rb in dcell-0.12.0.pre
- old
+ new
@@ -19,29 +19,26 @@
require 'dcell/info_service'
require 'dcell/registries/redis_adapter'
require 'dcell/registries/moneta_adapter'
-require 'dcell/registries/gossip/core'
-require 'dcell/registries/gossip_adapter'
-
require 'dcell/celluloid_ext'
# Distributed Celluloid
module DCell
class NotConfiguredError < RuntimeError; end # Not configured yet
- DEFAULT_PORT = 7777 # Default DCell port
+ DEFAULT_PORT = 7890 # Default DCell port
@config_lock = Mutex.new
class << self
attr_reader :me, :registry
# Configure DCell with the following options:
#
# * id: to identify the local node, defaults to hostname
- # * addr: 0MQ address of the local node (e.g. tcp://4.3.2.1:7777)
+ # * addr: 0MQ address of the local node (e.g. tcp://4.3.2.1:7890)
# *
def setup(options = {})
# Stringify keys :/
options = options.inject({}) { |h,(k,v)| h[k.to_s] = v; h }
@@ -52,20 +49,10 @@
'registry' => {'adapter' => 'redis', 'server' => 'localhost'}
}.merge(options)
@me = Node.new @configuration['id'], @configuration['addr']
- # Specify the directory server (defaults to me), and add it
- # to the local directory.
- directory = @configuration['directory'] || {}
- directory = directory.inject({}) { |h,(k,v)| h[k.to_s] = v; h }
- directory = {
- 'id' => @configuration['id'],
- 'addr' => @configuration['addr']
- }.merge(directory)
- DCell::Directory.set directory['id'], directory['addr']
-
registry_adapter = @configuration['registry'][:adapter] || @configuration['registry']['adapter']
raise ArgumentError, "no registry adapter given in config" unless registry_adapter
registry_class_name = registry_adapter.split("_").map(&:capitalize).join << "Adapter"
@@ -99,26 +86,26 @@
`hostname`.strip # Super creative I know
end
# Run the DCell application
def run
- DCell::Group.run
+ DCell::SupervisionGroup.run
end
# Run the DCell application in the background
def run!
- DCell::Group.run!
+ DCell::SupervisionGroup.run!
end
# Start combines setup and run! into a single step
def start(options = {})
setup options
run!
end
end
# DCell's actor dependencies
- class Group < Celluloid::Group
+ class SupervisionGroup < Celluloid::SupervisionGroup
supervise NodeManager, :as => :node_manager
supervise Server, :as => :dcell_server
supervise InfoService, :as => :info
end