Module: DCell
- Defined in:
- lib/dcell.rb,
lib/dcell/rpc.rb,
lib/dcell/node.rb,
lib/dcell/global.rb,
lib/dcell/router.rb,
lib/dcell/server.rb,
lib/dcell/version.rb,
lib/dcell/messages.rb,
lib/dcell/directory.rb,
lib/dcell/responses.rb,
lib/dcell/actor_proxy.rb,
lib/dcell/mailbox_proxy.rb,
lib/dcell/registries/zk_adapter.rb,
lib/dcell/registries/redis_adapter.rb,
lib/dcell/registries/moneta_adapter.rb
Overview
Distributed Celluloid
Defined Under Namespace
Modules: Directory, Global, Registry Classes: ActorProxy, ErrorResponse, Group, MailboxProxy, Message, Node, RPC, Response, Router, Server, SuccessResponse
Constant Summary collapse
- DEFAULT_PORT =
Default DCell port
7777
- EPOCH =
All things begin in 2012
Time.gm(2012)
- VERSION =
"0.9.0"
Class Attribute Summary collapse
-
.me ⇒ Object
readonly
Returns the value of attribute me.
-
.registry ⇒ Object
readonly
Returns the value of attribute registry.
Class Method Summary collapse
-
.addr ⇒ Object
(also: address)
Obtain the 0MQ address to the local mailbox.
-
.generate_node_id ⇒ Object
Attempt to generate a unique node ID for this machine.
-
.id ⇒ Object
Obtain the local node ID.
-
.run ⇒ Object
Run the DCell application.
-
.run! ⇒ Object
Run the DCell application in the background.
-
.setup(options = {}) ⇒ Object
Configure DCell with the following options:.
-
.start(options = {}) ⇒ Object
Start combines setup and run! into a single step.
Class Attribute Details
.me ⇒ Object (readonly)
Returns the value of attribute me.
29 30 31 |
# File 'lib/dcell.rb', line 29 def me @me end |
.registry ⇒ Object (readonly)
Returns the value of attribute registry.
29 30 31 |
# File 'lib/dcell.rb', line 29 def registry @registry end |
Class Method Details
.addr ⇒ Object Also known as: address
Obtain the 0MQ address to the local mailbox
73 |
# File 'lib/dcell.rb', line 73 def addr; @configuration['addr']; end |
.generate_node_id ⇒ Object
Attempt to generate a unique node ID for this machine
77 78 79 |
# File 'lib/dcell.rb', line 77 def generate_node_id `hostname`.strip # Super creative I know end |
.id ⇒ Object
Obtain the local node ID
70 |
# File 'lib/dcell.rb', line 70 def id; @configuration['id']; end |
.run ⇒ Object
Run the DCell application
82 83 84 |
# File 'lib/dcell.rb', line 82 def run DCell::Group.run end |
.run! ⇒ Object
Run the DCell application in the background
87 88 89 |
# File 'lib/dcell.rb', line 87 def run! DCell::Group.run! end |
.setup(options = {}) ⇒ Object
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)
*
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/dcell.rb', line 36 def setup( = {}) # Stringify keys :/ = .inject({}) { |h,(k,v)| h[k.to_s] = v; h } @config_lock.synchronize do @configuration = { 'id' => generate_node_id, 'addr' => "tcp://127.0.0.1:#{DEFAULT_PORT}", 'registry' => {'adapter' => 'redis', 'server' => 'localhost'} }.merge() @me = Node.new @configuration['id'], @configuration['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" begin registry_class = DCell::Registry.const_get registry_class_name rescue NameError raise ArgumentError, "invalid registry adapter: #{@configuration['registry']['adapter']}" end @registry = registry_class.new(@configuration['registry']) addr = @configuration['public'] || @configuration['addr'] DCell::Directory.set @configuration['id'], addr end me end |
.start(options = {}) ⇒ Object
Start combines setup and run! into a single step
92 93 94 95 |
# File 'lib/dcell.rb', line 92 def start( = {}) setup run! end |