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/explorer.rb,
lib/dcell/messages.rb,
lib/dcell/directory.rb,
lib/dcell/responses.rb,
lib/dcell/actor_proxy.rb,
lib/dcell/future_proxy.rb,
lib/dcell/info_service.rb,
lib/dcell/node_manager.rb,
lib/dcell/mailbox_proxy.rb,
lib/dcell/registries/zk_adapter.rb,
lib/dcell/registries/redis_adapter.rb,
lib/dcell/registries/moneta_adapter.rb,
lib/dcell/registries/cassandra_adapter.rb
Overview
not sure this is right yet … Keyspace “whatever” [
ColumnFamily "dcell" {
RowKey "nodes": {
<nodeid>: <address>,
<nodeid>: <address>,
...
}
RowKey "globals": {
<key>: <marshal blob>,
<key>: <marshal blob>,
...
}
}
]
Defined Under Namespace
Modules: Directory, Global, Registry Classes: Actor, ActorProxy, ErrorResponse, Explorer, FutureProxy, InfoService, MailboxProxy, Message, Node, NodeManager, NotConfiguredError, RPC, Response, Router, Server, SubjectProxy, SuccessResponse, SupervisionGroup, ThreadHandleProxy
Constant Summary collapse
- DEFAULT_PORT =
Default DCell port
7777
- Logger =
Celluloid::Logger
- VERSION =
"0.13.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.
34 35 36 |
# File 'lib/dcell.rb', line 34 def me @me end |
.registry ⇒ Object (readonly)
Returns the value of attribute registry.
34 35 36 |
# File 'lib/dcell.rb', line 34 def registry @registry end |
Class Method Details
.addr ⇒ Object Also known as: address
Obtain the 0MQ address to the local mailbox
81 |
# File 'lib/dcell.rb', line 81 def addr; @configuration['addr']; end |
.generate_node_id ⇒ Object
Attempt to generate a unique node ID for this machine
85 86 87 |
# File 'lib/dcell.rb', line 85 def generate_node_id `hostname`.strip # Super creative I know end |
.id ⇒ Object
Obtain the local node ID
75 76 77 78 |
# File 'lib/dcell.rb', line 75 def id raise NotConfiguredError, "please configure DCell with DCell.setup" unless @configuration @configuration['id'] end |
.run ⇒ Object
Run the DCell application
90 91 92 |
# File 'lib/dcell.rb', line 90 def run DCell::SupervisionGroup.run end |
.run! ⇒ Object
Run the DCell application in the background
95 96 97 |
# File 'lib/dcell.rb', line 95 def run! DCell::SupervisionGroup.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)
*
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 68 69 70 71 72 |
# File 'lib/dcell.rb', line 41 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
100 101 102 103 |
# File 'lib/dcell.rb', line 100 def start( = {}) setup run! end |