markbates-distribunaut 0.2.1.20090624214017 → 0.2.2.20090626214209

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,6 +17,7 @@ module Distribunaut # :nodoc:
17
17
  module Distributable
18
18
 
19
19
  def self.included(base) # :nodoc:
20
+ raise Distribunaut::Distributed::Errors::ApplicationNameUndefined.new if configatron.distribunaut.app_name.nil?
20
21
  base.class_eval do
21
22
  include ::DRbUndumped
22
23
  end
@@ -33,15 +34,23 @@ module Distribunaut # :nodoc:
33
34
  undef :id if method_defined?(:id)
34
35
  undef :inspect if method_defined?(:inspect)
35
36
  undef :to_s if method_defined?(:to_s)
37
+
38
+ def borrow(&block)
39
+ Distribunaut::Utils::Rinda.borrow(:space => :#{base},
40
+ :object => self,
41
+ :description => "#{base} Service",
42
+ :app_name => configatron.distribunaut.app_name.to_sym) do |tuple|
43
+ yield tuple.object
44
+ end
45
+ end
36
46
 
37
47
  end
38
48
  }
39
- obj = "Distribunaut::Distributed::#{c_name}Proxy".constantize.instance
40
- raise Distribunaut::Distributed::Errors::ApplicationNameUndefined.new if configatron.distribunaut.app_name.nil?
49
+ obj = "Distribunaut::Distributed::#{c_name}Proxy".constantize.instance
41
50
  Distribunaut::Utils::Rinda.register_or_renew(:space => "#{base}".to_sym,
42
- :object => obj,
43
- :description => "#{base} Service",
44
- :app_name => configatron.distribunaut.app_name.to_sym)
51
+ :object => obj,
52
+ :description => "#{base} Service",
53
+ :app_name => configatron.distribunaut.app_name.to_sym)
45
54
  end
46
55
 
47
56
  end # Distributable
@@ -35,6 +35,24 @@ module Distribunaut
35
35
  tuple = Distribunaut::Tuple.from_array(results)
36
36
  tuple.object
37
37
  end
38
+
39
+ def borrow(values = {}, &block)
40
+ tuple = build_tuple(values)
41
+ results = ring_server.take(tuple.to_array, tuple.timeout)
42
+ tuple = Distribunaut::Tuple.from_array(results)
43
+ tuple.space = "#{tuple.space}-onloan-#{Time.now}".to_sym
44
+ register(tuple)
45
+ begin
46
+ yield tuple if block_given?
47
+ rescue Exception => e
48
+ raise e
49
+ ensure
50
+ # (.+)-onloan-.+$
51
+ tuple.space.to_s.match(/(.+)-onloan-.+$/)
52
+ tuple.space = $1.to_sym
53
+ register(tuple)
54
+ end
55
+ end
38
56
 
39
57
  def available_services
40
58
  ring_server = self.ring_server
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.2.1.20090624214017
4
+ version: 0.2.2.20090626214209
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-06-24 00:00:00 -07:00
12
+ date: 2009-06-26 00:00:00 -07:00
13
13
  default_executable: distribunaut_ring_server
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency