agis 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/agis.rb +16 -14
  3. metadata +2 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c2efcb1eba59940bd4c9fa4c63baa465d2324a7
4
- data.tar.gz: 936b33de7cfcdcb35eba8d0cf8400472968383fc
3
+ metadata.gz: 1a3007830c900d69b3a8729fac5816644820e9ac
4
+ data.tar.gz: 9bba42fe778b4362540c6792d54b0e8f788f0fa4
5
5
  SHA512:
6
- metadata.gz: b598596dc39f627f3efdc55ef62001a885cf59fcb930710f30523289dc1bb198558ad4641aeeec3b3fd5e81a3c307d2b890b31256e7844fcdea5d6370736c77e
7
- data.tar.gz: 47ff87901ca0673f24085843de435f136283d5b8f234ccc1fcef7d0957ff4ee4392c4e7b2b77c48ca75b1110c8850fb9a12dfc35bde28dbf3247a83a6d603775
6
+ metadata.gz: b44f8bc9278c767fbdc9e83c4d29d30a6ad15dba40fa03684f51b01c0db9486b173cf36e1cb188b139c4b8e0a8985fe860da19cb957b6bb8d27c2843f984cd93
7
+ data.tar.gz: 5ab8555f66a9a617d96dd8bef79264351e4fb32a4099aad06c0ab3b7ceaedf3a057f286bf23922c673a28a64da1928c0b27aa3c1cf2e31ed674c65ec382c006e
@@ -86,31 +86,31 @@ module Agis
86
86
  end
87
87
 
88
88
  # create a method with no parameters
89
- def agis_defm0(name, timeout=nil, &b)
89
+ def agis_defm0(name, mode=:retry, timeout=nil, &b)
90
90
  @agis_methods ||= Hash.new
91
- @agis_methods[name] = [0, b, timeout]
91
+ @agis_methods[name] = {arity: 0, method: b, mode: mode, timeout: timeout}
92
92
  end
93
93
 
94
94
  # create a method with one parameter
95
- def agis_defm1(name, timeout=nil, &b)
95
+ def agis_defm1(name, mode=:retry, timeout=nil, &b)
96
96
  @agis_methods ||= Hash.new
97
- @agis_methods[name] = [1, b, timeout]
97
+ @agis_methods[name] = {arity: 1, method: b, mode: mode, timeout: timeout}
98
98
  end
99
99
 
100
100
  # create a method with two parameters
101
- def agis_defm2(name, timeout=nil, &b)
101
+ def agis_defm2(name, mode=:retry, timeout=nil, &b)
102
102
  @agis_methods ||= Hash.new
103
- @agis_methods[name] = [2, b, timeout]
103
+ @agis_methods[name] = {arity: 2, method: b, mode: mode, timeout: timeout}
104
104
  end
105
105
 
106
106
  # create a method with three parameters
107
- def agis_defm3(name, timeout=nil, &b)
107
+ def agis_defm3(name, mode=:retry, timeout=nil, &b)
108
108
  @agis_methods ||= Hash.new
109
- @agis_methods[name] = [3, b, timeout]
109
+ @agis_methods[name] = {arity: 3, method: b, mode: mode, timeout: timeout}
110
110
  end
111
111
 
112
112
  # alias for agis_defm3
113
- def agis_def(name, timeout=nil, &b)
113
+ def agis_def(name, mode=:retry, timeout=nil, &b)
114
114
  agis_defm3(name, timeout, b)
115
115
  end
116
116
 
@@ -154,8 +154,9 @@ module Agis
154
154
  return nil
155
155
  end
156
156
  mn = mni[2..-1]
157
- mc = @agis_methods[mn.to_sym][0]
158
- meti = @agis_methods[mn.to_sym][1]
157
+ mc = @agis_methods[mn.to_sym][:arity]
158
+ meti = @agis_methods[mn.to_sym][:method]
159
+ mrm = @agis_methods[mn.to_sym][:mode]
159
160
  case meti
160
161
  when Proc
161
162
  met = meti
@@ -172,6 +173,7 @@ module Agis
172
173
  #rescue Redis::Lock::LockNotAcquired
173
174
  # raise Agis::RedisLockExpired
174
175
  #end
176
+ popfive(redis) if mrm == :once
175
177
  case mc
176
178
  when 0
177
179
  ret = agis_aconv(met.call())
@@ -184,7 +186,7 @@ module Agis
184
186
  end
185
187
  redis.multi do
186
188
  redis.hset self.agis_returnbox, lusig, ret
187
- popfive redis
189
+ popfive(redis) if mrm == :retry
188
190
  end
189
191
  return :next
190
192
  rescue Agis::RedisLockExpired => e
@@ -262,7 +264,7 @@ module Agis
262
264
  # only be called inside an Agis method, where the box
263
265
  # is already guaranteed to be locked
264
266
  def agis_recall(mn, arg1=nil, arg2=nil, arg3=nil)
265
- meti = @agis_methods[mn.to_sym][1]
267
+ meti = @agis_methods[mn.to_sym][:method]
266
268
  case meti
267
269
  when Proc
268
270
  met = meti
@@ -272,7 +274,7 @@ module Agis
272
274
  met = self.method(mn.to_sym) # when proc is Nil, call the class methods all the same
273
275
  end
274
276
 
275
- case @agis_methods[mn.to_sym][0]
277
+ case @agis_methods[mn.to_sym][:arity]
276
278
  when 0
277
279
  return met.call()
278
280
  when 1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gert Oja
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-07 00:00:00.000000000 Z
11
+ date: 2015-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -70,4 +70,3 @@ signing_key:
70
70
  specification_version: 4
71
71
  summary: Messagebox Redis Actors for Ruby
72
72
  test_files: []
73
- has_rdoc: