Module: Distribunaut::Distributed

Defined in:
lib/distribunaut/distributed.rb,
lib/distribunaut/errors/errors.rb

Overview

:nodoc:

Defined Under Namespace

Modules: Errors

Class Method Summary collapse

Class Method Details

.const_missing(const) ⇒ Object

Looks up and tries to find the missing constant using the ring server.



5
6
7
# File 'lib/distribunaut/distributed.rb', line 5

def self.const_missing(const)
  Distribunaut::Utils::Rinda.read(:space => "#{const}".to_sym)
end

.lookup(address) ⇒ Object

Allows for the specific lookup of services on the ring server

Examples:

Distribunaut::Utils::Rinda.register_or_renew(:app_name => :app_1, :space => :Test, :object => "Hello World!")
Distribunaut::Utils::Rinda.register_or_renew(:app_name => :app_2, :space => :Test, :object => "Hello WORLD!")
Distribunaut::Distributed.lookup("distributed://app_1/Test") # => "Hello World!"
Distribunaut::Distributed.lookup("distributed://app_2/Test") # => "Hello WORLD!"


16
17
18
19
20
21
# File 'lib/distribunaut/distributed.rb', line 16

def self.lookup(address)
  uri = Addressable::URI.parse(address)
  path = uri.path[1..uri.path.size] # remove the first slash
  host = uri.host
  Distribunaut::Utils::Rinda.read(:space => path.to_sym, :app_name => host.to_sym)
end