markbates-distribunaut 0.0.2 → 0.0.2.20090406

Sign up to get free protection for your applications and to get access to all the features.
@@ -40,10 +40,9 @@ module Distribunaut # :nodoc:
40
40
 
41
41
  end
42
42
  }
43
- raise Distribunaut::Distributed::Errors::ApplicationNameUndefined.new if configatron.distribunaut.app_name.nil?
44
- Distribunaut::Distributed::Utils::Rinda.register_or_renew(:space => configatron.distribunaut.app_name.to_sym,
45
- :klass_def => "#{base}".to_sym,
46
- :object => "Distribunaut::Distributed::#{base}Proxy".constantize.instance)
43
+ obj = "Distribunaut::Distributed::#{base}Proxy".constantize.instance
44
+ Distribunaut::Distributed::Utils::Rinda.register_or_renew(:space => "#{base}".to_sym,
45
+ :object => obj)
47
46
  end
48
47
  end
49
48
 
@@ -3,21 +3,21 @@ module Distribunaut # :nodoc:
3
3
 
4
4
  # Looks up and tries to find the missing constant using the ring server.
5
5
  def self.const_missing(const)
6
- Distribunaut::Distributed::Utils::Rinda.read(:klass_def => "#{const}".to_sym)
6
+ Distribunaut::Distributed::Utils::Rinda.read(:space => "#{const}".to_sym)
7
7
  end
8
8
 
9
9
  # Allows for the specific lookup of services on the ring server
10
10
  #
11
11
  # Examples:
12
- # Distribunaut::Distributed::Utils::Rinda.register_or_renew(:space => :app_1, :klass_def => :Test, :object => "Hello World!")
13
- # Distribunaut::Distributed::Utils::Rinda.register_or_renew(:space => :app_2, :klass_def => :Test, :object => "Hello WORLD!")
12
+ # Distribunaut::Distributed::Utils::Rinda.register_or_renew(:app_name => :app_1, :space => :Test, :object => "Hello World!")
13
+ # Distribunaut::Distributed::Utils::Rinda.register_or_renew(:app_name => :app_2, :space => :Test, :object => "Hello WORLD!")
14
14
  # Distribunaut::Distributed.lookup("distributed://app_1/Test") # => "Hello World!"
15
15
  # Distribunaut::Distributed.lookup("distributed://app_2/Test") # => "Hello WORLD!"
16
16
  def self.lookup(address)
17
17
  uri = Addressable::URI.parse(address)
18
18
  path = uri.path[1..uri.path.size] # remove the first slash
19
19
  host = uri.host
20
- Distribunaut::Distributed::Utils::Rinda.read(:klass_def => path.to_sym, :space => host.to_sym)
20
+ Distribunaut::Distributed::Utils::Rinda.read(:space => path.to_sym, :app_name => host.to_sym)
21
21
  end
22
22
 
23
23
  end # Distributed
@@ -9,14 +9,6 @@ module Distribunaut
9
9
  super("APPLICATION: #{app_name} is not a known/registered distributed application.")
10
10
  end
11
11
  end
12
-
13
- # Raised when an unknown distributed route name for a distributed application is referenced.
14
- class UnknownRouteName < StandardError
15
- # Takes the application name and the route name.
16
- def initialize(app_name, route_name)
17
- super("ROUTE_NAME: #{route_name}, is not a known/registered distributed route name for application: #{app_name}.")
18
- end
19
- end
20
12
 
21
13
  # Raised when an application doesn't declare it's application name for use in a distributed system.
22
14
  class ApplicationNameUndefined < StandardError
@@ -27,7 +19,8 @@ module Distribunaut
27
19
  def inititalize(msg)
28
20
  super("Invalid addressable format: #{msg}")
29
21
  end
30
- end
22
+ end
23
+
31
24
  end # Errors
32
25
  end # Distributed
33
26
  end # Distribunaut
@@ -6,7 +6,7 @@ module Distribunaut
6
6
  def self.register_or_renew(options = {})
7
7
  options = handle_options(options)
8
8
  begin
9
- ring_server.take([options[:space], options[:klass_def], nil, nil], options[:timeout])
9
+ ring_server.take([options[:app_name], options[:space], nil, nil], options[:timeout])
10
10
  rescue Exception => e
11
11
  # Distribunaut.logger.error(e)
12
12
  end
@@ -15,8 +15,8 @@ module Distribunaut
15
15
 
16
16
  def self.register(options = {})
17
17
  options = handle_options(options)
18
- ring_server.write([options[:space],
19
- options[:klass_def],
18
+ ring_server.write([options[:app_name],
19
+ options[:space],
20
20
  options[:object],
21
21
  options[:description]],
22
22
  ::Rinda::SimpleRenewer.new)
@@ -34,12 +34,18 @@ module Distribunaut
34
34
 
35
35
  def self.read(options = {})
36
36
  options = handle_options(options)
37
- ring_server.read([options[:space], options[:klass_def], nil, options[:description]], options[:timeout])[2]
37
+ ring_server.read([options[:app_name], options[:space], nil, options[:description]], options[:timeout])[2]
38
38
  end
39
39
 
40
40
  private
41
41
  def self.handle_options(options = {})
42
- {:space => nil, :klass_def => nil, :object => nil, :description => nil, :timeout => configatron.distribunaut.timeout}.merge(options)
42
+ raise Distribunaut::Distributed::Errors::ApplicationNameUndefined.new if configatron.distribunaut.app_name.nil?
43
+ {:app_name => configatron.distribunaut.app_name,
44
+ :space => nil,
45
+ :object => nil,
46
+ :description => nil,
47
+ :timeout => configatron.distribunaut.timeout
48
+ }.merge(options)
43
49
  end
44
50
 
45
51
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markbates-distribunaut
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.2.20090406
5
5
  platform: ruby
6
6
  authors:
7
7
  - markbates
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-05 00:00:00 -07:00
12
+ date: 2009-04-06 00:00:00 -07:00
13
13
  default_executable: distribunaut_ring_server
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency