ruote-redis 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +10 -0
- data/CREDITS.txt +2 -1
- data/LICENSE.txt +1 -1
- data/README.rdoc +5 -4
- data/Rakefile +1 -1
- data/TODO.txt +3 -0
- data/lib/ruote/redis/storage.rb +121 -58
- data/lib/ruote/redis/version.rb +25 -1
- data/ruote-redis.gemspec +7 -4
- data/test/bm/loaded.rb +38 -0
- data/test/bughunt/launch_gun.rb +75 -0
- data/test/bughunt/put_gun.rb +36 -0
- data/test/{functional_connection.rb → connection.rb} +6 -4
- metadata +65 -76
data/CHANGELOG.txt
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
= ruote-redis - CHANGELOG.txt
|
3
3
|
|
4
4
|
|
5
|
+
== ruote-redis 2.3.0 released 2012/09/01
|
6
|
+
|
7
|
+
- fix issue uncovered by Base#remove_process
|
8
|
+
- fix update_rev (also update put_at)
|
9
|
+
- Storage#reconnect (shortcut to @redis.reconnect)
|
10
|
+
- further hardened Redis#keys_to_a
|
11
|
+
- simplified storage initialization
|
12
|
+
- using rpush and lpop for msgs (one del less per msg)
|
13
|
+
|
14
|
+
|
5
15
|
== ruote-redis 2.2.0 released 2011/03/01
|
6
16
|
|
7
17
|
- Ruote::Redis::Storage (instead of RedisStorage)
|
data/CREDITS.txt
CHANGED
data/LICENSE.txt
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
Copyright (c)
|
2
|
+
Copyright (c) 2005-2012, John Mettraux, jmettraux@gmail.com
|
3
3
|
|
4
4
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.rdoc
CHANGED
@@ -21,7 +21,8 @@ The storage is instantiate by passing a redis-rb instance to the storage.
|
|
21
21
|
|
22
22
|
Passing an em-redis instance might work, but I haven't tried.
|
23
23
|
|
24
|
-
Tested with Redis
|
24
|
+
Tested with Redis 2.0.1 (redis-rb 3.0.1) on Debian GNU/Linux.
|
25
|
+
Tested with Redis 2.4.16 (redis-rb 3.0.1) on OSX snoleo.
|
25
26
|
|
26
27
|
|
27
28
|
== running tests
|
@@ -31,20 +32,20 @@ assuming you have
|
|
31
32
|
ruote/
|
32
33
|
ruote-redis/
|
33
34
|
|
34
|
-
start a redis server instance (port 6379) and then
|
35
|
+
start a redis server instance (port 6379) and then
|
35
36
|
|
36
37
|
|
37
38
|
* unit tests :
|
38
39
|
|
39
40
|
get into ruote/ and do
|
40
41
|
|
41
|
-
ruby test/
|
42
|
+
RUOTE_STORAGE=redis ruby test/functional/storage.rb
|
42
43
|
|
43
44
|
* functional tests :
|
44
45
|
|
45
46
|
get into ruote/ and do
|
46
47
|
|
47
|
-
ruby test/functional/test.rb
|
48
|
+
RUOTE_STORAGE=redis ruby test/functional/test.rb
|
48
49
|
|
49
50
|
|
50
51
|
== license
|
data/Rakefile
CHANGED
data/TODO.txt
CHANGED
data/lib/ruote/redis/storage.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2012, John Mettraux, jmettraux@gmail.com
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files(the "Software"), to deal
|
@@ -22,8 +22,7 @@
|
|
22
22
|
# Made in Japan.
|
23
23
|
#++
|
24
24
|
|
25
|
-
|
26
|
-
# now letting the end-user doing this require
|
25
|
+
require 'redis'
|
27
26
|
|
28
27
|
require 'rufus-json'
|
29
28
|
require 'ruote/storage/base'
|
@@ -37,7 +36,7 @@ module Redis
|
|
37
36
|
# A Redis storage for ruote.
|
38
37
|
#
|
39
38
|
# The constructor accepts two arguments, the first one is a Redis instance
|
40
|
-
#( see http://github.com/ezmobius/redis-rb ), the second one is the classic
|
39
|
+
# ( see http://github.com/ezmobius/redis-rb ), the second one is the classic
|
41
40
|
# ruote engine options( see
|
42
41
|
# http://ruote.rubyforge.org/configuration.html#engine )
|
43
42
|
#
|
@@ -47,8 +46,7 @@ module Redis
|
|
47
46
|
#
|
48
47
|
# engine = Ruote::Engine.new(
|
49
48
|
# Ruote::Worker.new(
|
50
|
-
# Ruote::Redis::RedisStorage.new(
|
51
|
-
# ::Redis.new(:db => 14, :thread_safe => true), {})))
|
49
|
+
# Ruote::Redis::RedisStorage.new('db'=> 14, 'thread_safe' => true)))
|
52
50
|
#
|
53
51
|
#
|
54
52
|
# == em-redis
|
@@ -60,49 +58,129 @@ module Redis
|
|
60
58
|
# If you try and it works, feedback is welcome
|
61
59
|
# http://groups.google.com/group/openwferu-users
|
62
60
|
#
|
61
|
+
#
|
62
|
+
# == 'pop_count' option
|
63
|
+
#
|
64
|
+
# By default, when the worker queries this storage for msgs to process,
|
65
|
+
# the storage will try to pop 28 msgs. This number can be changed thanks
|
66
|
+
# to the 'pop_count' option, like in:
|
67
|
+
#
|
68
|
+
# engine = Ruote::Engine.new(
|
69
|
+
# Ruote::Worker.new(
|
70
|
+
# Ruote::Redis::RedisStorage.new(
|
71
|
+
# 'db'=> 14, 'thread_safe' => true, 'pop_count' => 56)))
|
72
|
+
#
|
73
|
+
# Don't put too high a number, it increases the chance of msgs getting lost
|
74
|
+
# in case of the worker going down.
|
75
|
+
#
|
76
|
+
# (if there is a need to avoid such a scenario in the future,
|
77
|
+
# Redis' rpoplpush might come in handy).
|
78
|
+
#
|
63
79
|
class Storage
|
64
80
|
|
65
81
|
include Ruote::StorageBase
|
66
82
|
|
67
83
|
attr_reader :redis
|
68
84
|
|
85
|
+
# Listing the redis options to differentiate them from ruote storage
|
86
|
+
# options.
|
87
|
+
#
|
88
|
+
REDIS_OPTIONS = %w[ host port path db thread_safe logger ]
|
89
|
+
|
69
90
|
# A Redis storage for ruote.
|
70
91
|
#
|
92
|
+
# Can be initialized in two ways
|
93
|
+
#
|
94
|
+
# Ruote::Redis::Storage.new(
|
95
|
+
# ::Redis.new(
|
96
|
+
# :host => '127.0.0.1',
|
97
|
+
# :db => 13,
|
98
|
+
# :thread_safe => true))
|
99
|
+
#
|
100
|
+
# or
|
101
|
+
#
|
102
|
+
# Ruote::Redis::Storage.new(
|
103
|
+
# 'host' => '127.0.0.1',
|
104
|
+
# 'db' => 13,
|
105
|
+
# 'thread_safe' => true)
|
106
|
+
#
|
107
|
+
# The first style is probably better avoided.
|
108
|
+
#
|
71
109
|
def initialize(redis, options={})
|
72
110
|
|
111
|
+
if options == {} && redis.is_a?(Hash)
|
112
|
+
|
113
|
+
redis_options, options = redis.partition { |k, v|
|
114
|
+
REDIS_OPTIONS.include?(k.to_s)
|
115
|
+
}
|
116
|
+
|
117
|
+
redis_options = Hash[redis_options.collect { |k, v| [ k.to_sym, v ] }]
|
118
|
+
options = Hash[options]
|
119
|
+
|
120
|
+
redis = ::Redis.new(redis_options)
|
121
|
+
end
|
122
|
+
|
73
123
|
@redis = redis
|
74
124
|
@options = options
|
75
125
|
|
76
|
-
|
77
|
-
|
126
|
+
@pop_count = @options['pop_count'] || 28
|
127
|
+
|
128
|
+
# Returns an array of the (String) keys that match the given pattern.
|
129
|
+
#
|
130
|
+
# Returns an empty array if anything goes wrong.
|
131
|
+
#
|
132
|
+
def @redis.keys_to_a(pattern)
|
133
|
+
|
134
|
+
if (a = (keys(pattern) rescue nil)).is_a?(Array)
|
135
|
+
a
|
136
|
+
else
|
137
|
+
[]
|
138
|
+
end
|
78
139
|
end
|
79
140
|
|
80
|
-
|
141
|
+
replace_engine_configuration(options)
|
81
142
|
end
|
82
143
|
|
83
144
|
# Returns true if the doc is successfully deleted.
|
84
145
|
#
|
85
146
|
def reserve(doc)
|
86
147
|
|
148
|
+
return true if doc['type'] == 'msgs'
|
149
|
+
|
87
150
|
(@redis.del(key_for(doc)) == 1)
|
88
151
|
end
|
89
152
|
|
90
153
|
def put_msg(action, options)
|
91
154
|
|
92
155
|
doc = prepare_msg_doc(action, options)
|
156
|
+
doc['put_at'] = Ruote.now_to_utc_s
|
93
157
|
|
94
|
-
@redis.
|
158
|
+
@redis.lpush('msgs', Rufus::Json.encode(doc))
|
95
159
|
|
96
160
|
nil
|
97
161
|
end
|
98
162
|
|
163
|
+
# Note: the worker argument is not used in this storage implementation.
|
164
|
+
#
|
165
|
+
def get_msgs
|
166
|
+
|
167
|
+
@redis.pipelined {
|
168
|
+
@pop_count.times { @redis.rpop('msgs') }
|
169
|
+
}.compact.collect { |d|
|
170
|
+
from_json(d)
|
171
|
+
}
|
172
|
+
end
|
173
|
+
|
99
174
|
def put_schedule(flavour, owner_fei, s, msg)
|
100
175
|
|
101
176
|
doc = prepare_schedule_doc(flavour, owner_fei, s, msg)
|
102
177
|
|
103
178
|
return nil unless doc
|
104
179
|
|
105
|
-
|
180
|
+
doc['_rev'] = '0'
|
181
|
+
doc['put_at'] = Ruote.now_to_utc_s
|
182
|
+
|
183
|
+
@redis.set(key_for(doc), Rufus::Json.encode(doc))
|
106
184
|
|
107
185
|
doc['_id']
|
108
186
|
end
|
@@ -141,9 +219,11 @@ module Redis
|
|
141
219
|
#
|
142
220
|
# put is successful (return nil)
|
143
221
|
#
|
144
|
-
|
145
|
-
|
146
|
-
|
222
|
+
doc = doc.send(
|
223
|
+
opts[:update_rev] ? :merge! : :merge,
|
224
|
+
{ '_rev' => (rev.to_i + 1).to_s, 'put_at' => Ruote.now_to_utc_s })
|
225
|
+
|
226
|
+
@redis.set(key, Rufus::Json.encode(doc))
|
147
227
|
|
148
228
|
nil
|
149
229
|
end
|
@@ -204,7 +284,9 @@ module Redis
|
|
204
284
|
|
205
285
|
elsif keys.first.is_a?(String)
|
206
286
|
|
207
|
-
keys.collect { |k|
|
287
|
+
keys.collect { |k|
|
288
|
+
@redis.keys_to_a("#{type}/*!#{k}#{type == 'schedules' ? '-*' : ''}")
|
289
|
+
}.flatten
|
208
290
|
|
209
291
|
else #if keys.first.is_a?(Regexp)
|
210
292
|
|
@@ -225,13 +307,13 @@ module Redis
|
|
225
307
|
limit = opts[:limit] || ids.length
|
226
308
|
ids = ids[skip, limit]
|
227
309
|
|
228
|
-
docs = ids.length > 0
|
229
|
-
docs = docs.
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
h
|
310
|
+
docs = ids.length > 0 && @redis.mget(*ids)
|
311
|
+
docs = docs.is_a?(Array) ? docs : []
|
312
|
+
|
313
|
+
docs = docs.each_with_object({}) do |doc, h|
|
314
|
+
next unless doc
|
315
|
+
doc = Rufus::Json.decode(doc)
|
316
|
+
h[doc['_id']] = doc
|
235
317
|
end
|
236
318
|
|
237
319
|
return docs.size if opts[:count]
|
@@ -252,15 +334,8 @@ module Redis
|
|
252
334
|
|
253
335
|
def purge!
|
254
336
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
# Returns a String containing a representation of the current content of
|
259
|
-
# in this Redis storage.
|
260
|
-
#
|
261
|
-
def dump(type)
|
262
|
-
|
263
|
-
@redis.keys_to_a("#{type}/*").sort.join("\n")
|
337
|
+
2.times { @redis.flushdb rescue nil }
|
338
|
+
# 2 times to work around Redis::ProtocolError '3'
|
264
339
|
end
|
265
340
|
|
266
341
|
# Shuts this worker down.
|
@@ -295,6 +370,13 @@ module Redis
|
|
295
370
|
@redis.keys_to_a("#{type}/*").each { |k| (@redis.del(k) rescue nil) }
|
296
371
|
end
|
297
372
|
|
373
|
+
# Simply calls @redis.reconnect
|
374
|
+
#
|
375
|
+
def reconnect
|
376
|
+
|
377
|
+
@redis.reconnect
|
378
|
+
end
|
379
|
+
|
298
380
|
protected
|
299
381
|
|
300
382
|
LOCK_KEY = /-lock$/
|
@@ -309,20 +391,18 @@ module Redis
|
|
309
391
|
|
310
392
|
loop do
|
311
393
|
|
312
|
-
|
394
|
+
break if @redis.setnx(kl, Time.now.to_f.to_s) != false
|
395
|
+
# locking successful
|
313
396
|
|
314
|
-
|
397
|
+
#
|
398
|
+
# already locked
|
315
399
|
|
316
|
-
|
400
|
+
t = @redis.get(kl)
|
317
401
|
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
sleep 0.007 # let's try to lock again after a while
|
322
|
-
else
|
402
|
+
@redis.del(kl) if t && Time.now.to_f - t.to_f > 60.0
|
403
|
+
# after 1 minute, locks time out
|
323
404
|
|
324
|
-
|
325
|
-
end
|
405
|
+
sleep 0.007 # let's try to lock again after a while
|
326
406
|
end
|
327
407
|
|
328
408
|
#@redis.expire(kl, 2)
|
@@ -354,23 +434,6 @@ module Redis
|
|
354
434
|
|
355
435
|
s ? Rufus::Json.decode(s) : nil
|
356
436
|
end
|
357
|
-
|
358
|
-
def to_json(doc, opts={})
|
359
|
-
|
360
|
-
Rufus::Json.encode(
|
361
|
-
opts[:delete] ? nil : doc.merge('put_at' => Ruote.now_to_utc_s))
|
362
|
-
end
|
363
|
-
|
364
|
-
# Don't put configuration if it's already in
|
365
|
-
#
|
366
|
-
# (prevent storages from trashing configuration...)
|
367
|
-
#
|
368
|
-
def put_configuration
|
369
|
-
|
370
|
-
return if get('configurations', 'engine')
|
371
|
-
|
372
|
-
put({ '_id' => 'engine', 'type' => 'configurations' }.merge(@options))
|
373
|
-
end
|
374
437
|
end
|
375
438
|
|
376
439
|
#
|
data/lib/ruote/redis/version.rb
CHANGED
@@ -1,8 +1,32 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2005-2012, John Mettraux, jmettraux@gmail.com
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files(the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
|
+
|
1
25
|
|
2
26
|
module Ruote
|
3
27
|
module Redis
|
4
28
|
|
5
|
-
VERSION = '2.
|
29
|
+
VERSION = '2.3.0'
|
6
30
|
end
|
7
31
|
end
|
8
32
|
|
data/ruote-redis.gemspec
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
|
3
2
|
Gem::Specification.new do |s|
|
4
3
|
|
5
4
|
s.name = 'ruote-redis'
|
6
|
-
|
5
|
+
|
6
|
+
s.version = File.read(
|
7
|
+
File.expand_path('../lib/ruote/redis/version.rb', __FILE__)
|
8
|
+
).match(/ VERSION *= *['"]([^'"]+)/)[1]
|
9
|
+
|
7
10
|
s.platform = Gem::Platform::RUBY
|
8
11
|
s.authors = [ 'John Mettraux' ]
|
9
12
|
s.email = [ 'jmettraux@gmail.com' ]
|
@@ -12,7 +15,7 @@ Gem::Specification.new do |s|
|
|
12
15
|
s.summary = 'Redis storage for ruote (a Ruby workflow engine)'
|
13
16
|
s.description = %q{
|
14
17
|
Redis storage for ruote (a Ruby workflow engine)
|
15
|
-
}
|
18
|
+
}
|
16
19
|
|
17
20
|
#s.files = `git ls-files`.split("\n")
|
18
21
|
s.files = Dir[
|
@@ -21,7 +24,7 @@ Redis storage for ruote (a Ruby workflow engine)
|
|
21
24
|
'*.gemspec', '*.txt', '*.rdoc', '*.md'
|
22
25
|
]
|
23
26
|
|
24
|
-
s.add_runtime_dependency 'redis'
|
27
|
+
s.add_runtime_dependency 'redis'#, '>= 2.2.2'
|
25
28
|
s.add_runtime_dependency 'ruote', ">= #{s.version}"
|
26
29
|
|
27
30
|
s.add_development_dependency 'rake'
|
data/test/bm/loaded.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
$: << File.expand_path('../../../lib', __FILE__)
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
|
6
|
+
require 'rufus-json/automatic'
|
7
|
+
require 'ruote'
|
8
|
+
require 'ruote-redis'
|
9
|
+
|
10
|
+
ruote =
|
11
|
+
Ruote::Dashboard.new(
|
12
|
+
Ruote::Worker.new(
|
13
|
+
Ruote::Redis::Storage.new('db' => 15, 'thread_safe' => true)))
|
14
|
+
|
15
|
+
ruote.storage.purge!
|
16
|
+
#ruote.noisy = true
|
17
|
+
|
18
|
+
ruote.register 'toto' do |workitem|
|
19
|
+
workitem.fields['seen'] = Time.now.to_s
|
20
|
+
end
|
21
|
+
|
22
|
+
t = Time.now
|
23
|
+
|
24
|
+
50.times do
|
25
|
+
wfid = ruote.launch(Ruote.define do
|
26
|
+
toto; toto; toto; toto; toto
|
27
|
+
end)
|
28
|
+
p wfid
|
29
|
+
end
|
30
|
+
|
31
|
+
loop do
|
32
|
+
count = ruote.storage.get_many('expressions', nil, :count => true)
|
33
|
+
p count
|
34
|
+
break if count < 1
|
35
|
+
end
|
36
|
+
|
37
|
+
p Time.now - t
|
38
|
+
|
@@ -0,0 +1,75 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote-redis
|
4
|
+
#
|
5
|
+
# Started in Narita, finished in Santa Barbara
|
6
|
+
#
|
7
|
+
# Fri Feb 3 14:47:04 JST 2012
|
8
|
+
#
|
9
|
+
|
10
|
+
$:.unshift(File.expand_path('../../../../ruote/lib', __FILE__))
|
11
|
+
$:.unshift(File.expand_path('../../../lib', __FILE__))
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
|
15
|
+
require 'pp'
|
16
|
+
|
17
|
+
require 'rufus-json/automatic'
|
18
|
+
require 'redis'
|
19
|
+
|
20
|
+
require 'ruote'
|
21
|
+
#require 'ruote/storage/fs_storage'
|
22
|
+
require 'ruote-redis'
|
23
|
+
|
24
|
+
N = 1000
|
25
|
+
|
26
|
+
$dash = Ruote::Dashboard.new(
|
27
|
+
Ruote::Worker.new(
|
28
|
+
Ruote::Redis::Storage.new(
|
29
|
+
'db' => 13, 'thread_safe' => true)))
|
30
|
+
#Ruote::HashStorage.new))
|
31
|
+
#Ruote::FsStorage.new('work')))
|
32
|
+
|
33
|
+
p $dash.storage_participant.size
|
34
|
+
$dash.storage.purge!
|
35
|
+
#p $dash.processes.size
|
36
|
+
p $dash.storage_participant.size
|
37
|
+
|
38
|
+
#exit 0
|
39
|
+
|
40
|
+
$dash.register 'toto', Ruote::StorageParticipant
|
41
|
+
|
42
|
+
$pdef = Ruote.define do
|
43
|
+
sequence do
|
44
|
+
sequence do
|
45
|
+
toto
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
$wfids = []
|
51
|
+
|
52
|
+
N.times do |i|
|
53
|
+
$wfids << $dash.launch($pdef)
|
54
|
+
print (i % 10 == 0) ? i : '.'; STDOUT.flush
|
55
|
+
#sleep 0.001 # jams...
|
56
|
+
#sleep 0.005
|
57
|
+
end
|
58
|
+
|
59
|
+
puts
|
60
|
+
puts 'launch done'
|
61
|
+
|
62
|
+
t = Time.now
|
63
|
+
|
64
|
+
while (n = $dash.storage_participant.size) < N
|
65
|
+
sleep 0.050
|
66
|
+
p n if (Time.now - t) > 60.0
|
67
|
+
break if (Time.now - t) > 2 * 60.0
|
68
|
+
end
|
69
|
+
|
70
|
+
puts "took #{Time.now - t}s"
|
71
|
+
p $dash.storage_participant.size
|
72
|
+
|
73
|
+
$dash.shutdown
|
74
|
+
$dash.storage.purge!
|
75
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
$:.unshift(File.expand_path('../../../../ruote/lib', __FILE__))
|
3
|
+
$:.unshift(File.expand_path('../../../lib', __FILE__))
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
|
7
|
+
require 'pp'
|
8
|
+
|
9
|
+
require 'redis'
|
10
|
+
|
11
|
+
N = 10_000
|
12
|
+
|
13
|
+
redis = ::Redis.new('db' => 12, 'thread_safe' => true)
|
14
|
+
|
15
|
+
p redis.del('put_gun')
|
16
|
+
|
17
|
+
N.times do
|
18
|
+
msg = (Time.now.to_f.to_s + '__') * 50
|
19
|
+
redis.rpush('put_gun', msg)
|
20
|
+
end
|
21
|
+
|
22
|
+
p redis.llen('put_gun')
|
23
|
+
|
24
|
+
results = []
|
25
|
+
|
26
|
+
loop do
|
27
|
+
x = redis.lpop('put_gun')
|
28
|
+
break unless x
|
29
|
+
results << x
|
30
|
+
end
|
31
|
+
|
32
|
+
p results.size
|
33
|
+
p results.sort.uniq.size
|
34
|
+
|
35
|
+
# it's always N, redis is great
|
36
|
+
|
@@ -21,11 +21,13 @@ class RrLogger
|
|
21
21
|
end
|
22
22
|
|
23
23
|
|
24
|
-
def new_storage
|
24
|
+
def new_storage(opts)
|
25
|
+
|
26
|
+
#Ruote::Redis::Storage.new(
|
27
|
+
# ::Redis.new(:db => 14, :thread_safe => true, :logger => RrLogger.new),
|
28
|
+
# opts)
|
25
29
|
|
26
30
|
Ruote::Redis::Storage.new(
|
27
|
-
|
28
|
-
#::Redis.new(:db => 14, :thread_safe => true, :logger => RrLogger.new),
|
29
|
-
opts)
|
31
|
+
opts.merge('db' => 14, 'thread_safe' => true, 'pop_count' => 28))
|
30
32
|
end
|
31
33
|
|
metadata
CHANGED
@@ -1,119 +1,108 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruote-redis
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 2
|
7
|
-
- 2
|
8
|
-
- 0
|
9
|
-
version: 2.2.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.3.0
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- John Mettraux
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-09-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: redis
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
- 2
|
30
|
-
- 1
|
31
|
-
- 1
|
32
|
-
version: 2.1.1
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
33
22
|
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: ruote
|
37
23
|
prerelease: false
|
38
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: ruote
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
39
33
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
- 2
|
45
|
-
- 2
|
46
|
-
- 0
|
47
|
-
version: 2.2.0
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.3.0
|
48
38
|
type: :runtime
|
49
|
-
version_requirements: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: rake
|
52
39
|
prerelease: false
|
53
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.3.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
54
49
|
none: false
|
55
|
-
requirements:
|
56
|
-
- -
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
|
59
|
-
- 0
|
60
|
-
version: "0"
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
61
54
|
type: :development
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: ! "\nRedis storage for ruote (a Ruby workflow engine)\n "
|
63
|
+
email:
|
66
64
|
- jmettraux@gmail.com
|
67
65
|
executables: []
|
68
|
-
|
69
66
|
extensions: []
|
70
|
-
|
71
67
|
extra_rdoc_files: []
|
72
|
-
|
73
|
-
files:
|
68
|
+
files:
|
74
69
|
- Rakefile
|
75
70
|
- lib/ruote/redis/storage.rb
|
76
71
|
- lib/ruote/redis/version.rb
|
77
72
|
- lib/ruote/redis.rb
|
78
73
|
- lib/ruote-redis.rb
|
79
|
-
- test/
|
74
|
+
- test/bm/loaded.rb
|
75
|
+
- test/bughunt/launch_gun.rb
|
76
|
+
- test/bughunt/put_gun.rb
|
77
|
+
- test/connection.rb
|
80
78
|
- ruote-redis.gemspec
|
81
79
|
- CHANGELOG.txt
|
82
80
|
- CREDITS.txt
|
83
81
|
- LICENSE.txt
|
84
82
|
- TODO.txt
|
85
83
|
- README.rdoc
|
86
|
-
has_rdoc: true
|
87
84
|
homepage: http://ruote.rubyforge.org
|
88
85
|
licenses: []
|
89
|
-
|
90
86
|
post_install_message:
|
91
87
|
rdoc_options: []
|
92
|
-
|
93
|
-
require_paths:
|
88
|
+
require_paths:
|
94
89
|
- lib
|
95
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
91
|
none: false
|
97
|
-
requirements:
|
98
|
-
- -
|
99
|
-
- !ruby/object:Gem::Version
|
100
|
-
|
101
|
-
|
102
|
-
version: "0"
|
103
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
97
|
none: false
|
105
|
-
requirements:
|
106
|
-
- -
|
107
|
-
- !ruby/object:Gem::Version
|
108
|
-
|
109
|
-
- 0
|
110
|
-
version: "0"
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
111
102
|
requirements: []
|
112
|
-
|
113
103
|
rubyforge_project: ruote
|
114
|
-
rubygems_version: 1.
|
104
|
+
rubygems_version: 1.8.24
|
115
105
|
signing_key:
|
116
106
|
specification_version: 3
|
117
107
|
summary: Redis storage for ruote (a Ruby workflow engine)
|
118
108
|
test_files: []
|
119
|
-
|