ruote-couch 2.1.10 → 2.1.11
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.
- data/CHANGELOG.txt +11 -1
- data/CREDITS.txt +18 -0
- data/README.rdoc +1 -1
- data/Rakefile +15 -17
- data/TODO.txt +3 -0
- data/lib/ruote/couch/database.rb +72 -39
- data/lib/ruote/couch/storage.rb +33 -42
- data/lib/ruote/couch/version.rb +1 -1
- data/ruote-couch.gemspec +9 -9
- data/test/functional_connection.rb +24 -8
- metadata +8 -8
- data/test/functional/ft_0_long_polling.rb +0 -66
data/CHANGELOG.txt
CHANGED
@@ -2,10 +2,20 @@
|
|
2
2
|
= ruote-couch - CHANGELOG.txt
|
3
3
|
|
4
4
|
|
5
|
+
== ruote-couch 2.1.11 released 2010/10/01
|
6
|
+
|
7
|
+
- storage#shutdown back in business (for the sake of tests mostly)
|
8
|
+
- get_many(x, y, :descending => true) support
|
9
|
+
- adapted for engine.processes pagination
|
10
|
+
- workitems.by_participant() :skip and :limit support
|
11
|
+
- get_many(x, y, :count => true) support
|
12
|
+
- a database.purge! that can't be mislead by cache issues
|
13
|
+
|
14
|
+
|
5
15
|
== ruote-couch 2.1.10 released 2010/06/15
|
6
16
|
|
7
17
|
- storage#ids not returning design doc ids anymore
|
8
|
-
- now using CouchDB 0.11 continuous&
|
18
|
+
- now using CouchDB 0.11 ?feed=continuous&include_docs=true
|
9
19
|
- multi-worker hardened
|
10
20
|
- adapted #query_workitems to ruote 2.1.10
|
11
21
|
|
data/CREDITS.txt
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
= ruote-couch CREDITS.txt
|
3
|
+
|
4
|
+
|
5
|
+
== authors
|
6
|
+
|
7
|
+
- John Mettraux - http://github.com/jmettraux
|
8
|
+
|
9
|
+
|
10
|
+
== contributors
|
11
|
+
|
12
|
+
- Torsten Schoenebaum - http://github.com/tosch
|
13
|
+
|
14
|
+
|
15
|
+
== many thanks to
|
16
|
+
|
17
|
+
- the CouchDB team for their great project
|
18
|
+
|
data/README.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -32,8 +32,9 @@ CouchDB storage for ruote 2.1 (ruby workflow engine)
|
|
32
32
|
|
33
33
|
gem.test_file = 'test/test.rb'
|
34
34
|
|
35
|
-
gem.add_dependency 'ruote', ">= #{Ruote::Couch::VERSION}"
|
36
|
-
gem.add_dependency '
|
35
|
+
#gem.add_dependency 'ruote', ">= #{Ruote::Couch::VERSION}"
|
36
|
+
gem.add_dependency 'ruote', ">= 2.1.11"
|
37
|
+
gem.add_dependency 'rufus-jig', '>= 0.1.23'
|
37
38
|
gem.add_development_dependency 'yard'
|
38
39
|
gem.add_development_dependency 'rake'
|
39
40
|
gem.add_development_dependency 'jeweler'
|
@@ -61,33 +62,30 @@ end
|
|
61
62
|
#
|
62
63
|
# DOC
|
63
64
|
|
64
|
-
|
65
|
+
#
|
66
|
+
# make sure to have rdoc 2.5.x to run that
|
67
|
+
#
|
68
|
+
require 'rake/rdoctask'
|
69
|
+
Rake::RDocTask.new do |rd|
|
65
70
|
|
66
|
-
|
71
|
+
rd.main = 'README.rdoc'
|
72
|
+
rd.rdoc_dir = 'rdoc/ruote-couch_rdoc'
|
67
73
|
|
68
|
-
|
69
|
-
|
70
|
-
'-o', 'html/ruote-couch', '--title',
|
71
|
-
"ruote-couch #{Ruote::Couch::VERSION}"
|
72
|
-
]
|
73
|
-
end
|
74
|
+
rd.rdoc_files.include(
|
75
|
+
'README.rdoc', 'CHANGELOG.txt', 'CREDITS.txt', 'lib/**/*.rb')
|
74
76
|
|
75
|
-
|
76
|
-
|
77
|
-
task :yard do
|
78
|
-
abort "YARD is not available : sudo gem install yard"
|
79
|
-
end
|
77
|
+
rd.title = "ruote-couch #{Ruote::Couch::VERSION}"
|
80
78
|
end
|
81
79
|
|
82
80
|
|
83
81
|
#
|
84
82
|
# TO THE WEB
|
85
83
|
|
86
|
-
task :
|
84
|
+
task :upload_rdoc => [ :clean, :rdoc ] do
|
87
85
|
|
88
86
|
account = 'jmettraux@rubyforge.org'
|
89
87
|
webdir = '/var/www/gforge-projects/ruote'
|
90
88
|
|
91
|
-
sh "rsync -azv -e ssh
|
89
|
+
sh "rsync -azv -e ssh rdoc/ruote-couch_rdoc #{account}:#{webdir}/"
|
92
90
|
end
|
93
91
|
|
data/TODO.txt
CHANGED
data/lib/ruote/couch/database.rb
CHANGED
@@ -39,11 +39,7 @@ module Ruote::Couch
|
|
39
39
|
|
40
40
|
attr_reader :couch
|
41
41
|
|
42
|
-
def initialize (host, port, type, name)
|
43
|
-
|
44
|
-
#opts = { :re_put_ok => re_put_ok }
|
45
|
-
opts = {}
|
46
|
-
#opts[:timeout] = TODO
|
42
|
+
def initialize (host, port, type, name, opts={})
|
47
43
|
|
48
44
|
@couch = Rufus::Jig::Couch.new(host, port, name, opts)
|
49
45
|
|
@@ -79,29 +75,49 @@ module Ruote::Couch
|
|
79
75
|
# without this, test/functional/ct_0 fails after 1 to 10 runs...
|
80
76
|
|
81
77
|
r
|
78
|
+
|
79
|
+
rescue Rufus::Jig::TimeoutError => te
|
80
|
+
true
|
82
81
|
end
|
83
82
|
|
83
|
+
# The get_many used by msgs, configurations and variables.
|
84
|
+
#
|
84
85
|
def get_many (key, opts)
|
85
86
|
|
86
|
-
|
87
|
+
return query('_all_docs?include_docs=true') if ( ! key) && opts.size < 1
|
87
88
|
|
88
|
-
|
89
|
+
is = ids
|
89
90
|
|
90
|
-
|
91
|
-
# naive...
|
91
|
+
return is.length if opts[:count]
|
92
92
|
|
93
|
-
|
94
|
-
end
|
93
|
+
is = is.reverse if opts[:descending]
|
95
94
|
|
96
|
-
|
95
|
+
if key
|
96
|
+
keys = Array(key).map { |k| k.is_a?(String) ? "!#{k}" : k }
|
97
|
+
is = is.select { |i| Ruote::StorageBase.key_match?(keys, i) }
|
98
|
+
end
|
99
|
+
|
100
|
+
skip = opts[:skip] || 0
|
101
|
+
limit = opts[:limit] || is.length
|
102
|
+
|
103
|
+
is = is[skip, limit]
|
104
|
+
|
105
|
+
query_by_post('_all_docs?include_docs=true', is)
|
106
|
+
|
107
|
+
# TODO
|
108
|
+
# maybe _count come be of use here
|
109
|
+
# http://wiki.apache.org/couchdb/Built-In_Reduce_Functions
|
110
|
+
end
|
97
111
|
|
98
112
|
# Returns a sorted list of the ids of all the docs in this database.
|
99
113
|
#
|
100
114
|
def ids
|
101
115
|
|
102
|
-
|
103
|
-
|
104
|
-
|
116
|
+
@couch.get('_all_docs')['rows'].collect { |r|
|
117
|
+
r['id']
|
118
|
+
}.reject { |i|
|
119
|
+
DESIGN_DOC_REGEX.match(i)
|
120
|
+
}
|
105
121
|
end
|
106
122
|
|
107
123
|
def dump
|
@@ -116,18 +132,22 @@ module Ruote::Couch
|
|
116
132
|
end
|
117
133
|
end
|
118
134
|
|
119
|
-
#
|
120
|
-
#
|
121
|
-
|
122
|
-
|
135
|
+
# Makes sure to close the HTTP connection down.
|
136
|
+
#
|
137
|
+
def shutdown
|
138
|
+
|
139
|
+
@couch.close
|
140
|
+
end
|
123
141
|
|
124
142
|
# Deletes all the documents in this database.
|
125
143
|
#
|
126
144
|
def purge!
|
127
145
|
|
146
|
+
@couch.http.cache.clear
|
128
147
|
@couch.get('_all_docs')['rows'].each do |row|
|
148
|
+
next if row['id'].match(/^\_design\//)
|
129
149
|
doc = { '_id' => row['id'], '_rev' => row['value']['rev'] }
|
130
|
-
@couch.delete(doc)
|
150
|
+
@couch.delete(doc)
|
131
151
|
end
|
132
152
|
#
|
133
153
|
# which is faster than
|
@@ -144,22 +164,36 @@ module Ruote::Couch
|
|
144
164
|
# nothing to do for a index-less database
|
145
165
|
end
|
146
166
|
|
147
|
-
#
|
167
|
+
# These options are known and passed to CouchDB.
|
168
|
+
#
|
169
|
+
QUERY_OPTIONS = [ :skip, :limit, :descending ]
|
170
|
+
|
171
|
+
# :limit and :skip support
|
148
172
|
#
|
149
173
|
def query_options (opts)
|
150
174
|
|
151
|
-
opts = opts.select { |k, v|
|
175
|
+
opts = opts.select { |k, v| QUERY_OPTIONS.include?(k) && v != nil }
|
152
176
|
|
153
177
|
s = opts.collect { |k, v| "#{k}=#{v}" }.join('&')
|
154
178
|
|
155
179
|
s.length > 0 ? "&#{s}" : ''
|
156
180
|
end
|
157
181
|
|
182
|
+
# Used by #get_many and #ids when filtering design documents out of
|
183
|
+
# '_all_docs'.
|
184
|
+
#
|
185
|
+
DESIGN_DOC_REGEX = /^\_design\//
|
186
|
+
|
187
|
+
def filter_design_docs (docs)
|
188
|
+
|
189
|
+
docs.reject { |d| DESIGN_DOC_REGEX.match(d['_id']) }
|
190
|
+
end
|
191
|
+
|
158
192
|
def query (uri)
|
159
193
|
|
160
194
|
rs = @couch.get(uri)
|
161
195
|
|
162
|
-
rs['rows'].collect { |e| e['doc'] }
|
196
|
+
filter_design_docs(rs['rows'].collect { |e| e['doc'] })
|
163
197
|
end
|
164
198
|
|
165
199
|
def query_by_post (uri, keys)
|
@@ -168,7 +202,7 @@ module Ruote::Couch
|
|
168
202
|
|
169
203
|
rs = @couch.post(uri, keys)
|
170
204
|
|
171
|
-
rs['rows'].collect { |e| e['doc'] }.uniq
|
205
|
+
filter_design_docs(rs['rows'].collect { |e| e['doc'] }.uniq)
|
172
206
|
end
|
173
207
|
end
|
174
208
|
|
@@ -177,27 +211,23 @@ module Ruote::Couch
|
|
177
211
|
#
|
178
212
|
class WfidIndexedDatabase < Database
|
179
213
|
|
214
|
+
# The get_many used by errors, expressions and schedules.
|
215
|
+
#
|
180
216
|
def get_many (key, opts)
|
181
217
|
|
182
|
-
|
183
|
-
# let's use the couch view...
|
184
|
-
|
185
|
-
query(
|
186
|
-
"_design/ruote/_view/by_wfid?key=%22#{m[1]}%22" +
|
187
|
-
"&include_docs=true#{query_options(opts)}")
|
218
|
+
return super(key, opts) unless key.is_a?(String)
|
188
219
|
|
189
|
-
|
190
|
-
# let's use the naive default implementation
|
220
|
+
# key is a wfid
|
191
221
|
|
192
|
-
|
193
|
-
end
|
222
|
+
query("_design/ruote/_view/by_wfid?key=%22#{key}%22&include_docs=true")
|
194
223
|
end
|
195
224
|
|
196
225
|
# Used by WorkitemDatabase#query
|
197
226
|
#
|
198
227
|
def by_wfid (wfid)
|
199
228
|
|
200
|
-
get_many(/!#{wfid}$/, {})
|
229
|
+
#get_many(/!#{wfid}$/, {})
|
230
|
+
get_many(wfid, {})
|
201
231
|
end
|
202
232
|
|
203
233
|
# Returns the design document that goes with this class of database
|
@@ -215,8 +245,12 @@ module Ruote::Couch
|
|
215
245
|
'_id' => '_design/ruote',
|
216
246
|
'views' => {
|
217
247
|
'by_wfid' => {
|
218
|
-
'map' =>
|
219
|
-
|
248
|
+
'map' => %{
|
249
|
+
function (doc) {
|
250
|
+
if (doc.wfid) emit(doc.wfid, null);
|
251
|
+
else if (doc.fei) emit(doc.fei.wfid, null);
|
252
|
+
}
|
253
|
+
}
|
220
254
|
}
|
221
255
|
}
|
222
256
|
}
|
@@ -278,8 +312,7 @@ module Ruote::Couch
|
|
278
312
|
return by_wfid(wfid) # if wfid
|
279
313
|
end
|
280
314
|
|
281
|
-
return get_many(nil, {})
|
282
|
-
if criteria.empty?
|
315
|
+
return get_many(nil, {}) if criteria.empty?
|
283
316
|
|
284
317
|
cr = criteria.collect { |fname, fvalue| { fname => fvalue } }
|
285
318
|
|
data/lib/ruote/couch/storage.rb
CHANGED
@@ -47,47 +47,41 @@ module Couch
|
|
47
47
|
# Hooks the storage to a CouchDB instance.
|
48
48
|
#
|
49
49
|
# The main option is 'couch_prefix', which indicate which prefix should be
|
50
|
-
# added to all the database names used by this storage.
|
50
|
+
# added to all the database names used by this storage. 'prefix' is accepted
|
51
|
+
# as well.
|
51
52
|
#
|
52
|
-
|
53
|
-
# is the long-polling timeout. For functional test it is set to two seconds
|
54
|
-
# but for a production system, something like 10 minutes or 8 hours might
|
55
|
-
# be OK.
|
56
|
-
#
|
57
|
-
def initialize (host, port, options={})
|
53
|
+
def initialize (*args)
|
58
54
|
|
59
|
-
|
60
|
-
|
55
|
+
hc = Rufus::Jig::HttpCore.new(*args)
|
56
|
+
# leverage the argument parsing logic in there
|
61
57
|
|
62
|
-
@
|
58
|
+
@host = hc.host
|
59
|
+
@port = hc.port
|
63
60
|
|
64
|
-
@
|
65
|
-
@prefix = "#{@prefix}_" if @prefix.size > 0
|
61
|
+
@options = hc.options
|
66
62
|
|
67
|
-
|
68
|
-
@
|
63
|
+
@prefix = hc.options['couch_prefix'] || hc.options['prefix'] || ''
|
64
|
+
@prefix = "#{@prefix}_" if @prefix.size > 0
|
69
65
|
|
70
66
|
@dbs = {}
|
71
67
|
|
72
|
-
%w[ msgs
|
68
|
+
%w[ msgs configurations variables ].each do |type|
|
73
69
|
|
74
70
|
@dbs[type] = Database.new(
|
75
|
-
@host, @port, type, "#{@prefix}ruote_#{type}")
|
71
|
+
@host, @port, type, "#{@prefix}ruote_#{type}", @options)
|
76
72
|
end
|
77
73
|
|
78
|
-
|
79
|
-
@host, @port, 'errors', "#{@prefix}ruote_errors")
|
74
|
+
%w[ errors expressions schedules ].each do |type|
|
80
75
|
|
81
|
-
|
82
|
-
|
83
|
-
|
76
|
+
@dbs[type] = WfidIndexedDatabase.new(
|
77
|
+
@host, @port, type, "#{@prefix}ruote_#{type}", @options)
|
78
|
+
end
|
84
79
|
|
85
80
|
@dbs['workitems'] = WorkitemDatabase.new(
|
86
|
-
@host, @port, 'workitems', "#{@prefix}ruote_workitems")
|
81
|
+
@host, @port, 'workitems', "#{@prefix}ruote_workitems", @options)
|
87
82
|
|
88
83
|
put_configuration
|
89
84
|
|
90
|
-
#@zero_msgs_offset = @zeroes
|
91
85
|
@msgs_thread = nil
|
92
86
|
@msgs_queue = ::Queue.new
|
93
87
|
|
@@ -131,18 +125,6 @@ module Couch
|
|
131
125
|
#@dbs.values.each { |db| db.shutdown }
|
132
126
|
end
|
133
127
|
|
134
|
-
# Used when doing integration tests, removes all
|
135
|
-
# msgs, schedules, errors, expressions and workitems.
|
136
|
-
#
|
137
|
-
# NOTE that it doesn't remove engine variables (danger)
|
138
|
-
#
|
139
|
-
def clear
|
140
|
-
|
141
|
-
%w[ msgs schedules errors expressions workitems ].each do |type|
|
142
|
-
@dbs[type].purge!
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
128
|
def dump (type)
|
147
129
|
|
148
130
|
@dbs[type].dump
|
@@ -150,9 +132,7 @@ module Couch
|
|
150
132
|
|
151
133
|
def shutdown
|
152
134
|
|
153
|
-
|
154
|
-
|
155
|
-
#@poller.kill if @poller
|
135
|
+
@dbs.values.each { |db| db.shutdown }
|
156
136
|
|
157
137
|
@msgs_thread.kill rescue nil
|
158
138
|
@schedules_thread.kill rescue nil
|
@@ -179,11 +159,11 @@ module Couch
|
|
179
159
|
# A provision made for workitems, allow to query them directly by
|
180
160
|
# participant name.
|
181
161
|
#
|
182
|
-
def by_participant (type, participant_name)
|
162
|
+
def by_participant (type, participant_name, opts)
|
183
163
|
|
184
164
|
raise NotImplementedError if type != 'workitems'
|
185
165
|
|
186
|
-
@dbs['workitems'].by_participant(participant_name)
|
166
|
+
@dbs['workitems'].by_participant(participant_name, opts)
|
187
167
|
end
|
188
168
|
|
189
169
|
def by_field (type, field, value=nil)
|
@@ -195,7 +175,11 @@ module Couch
|
|
195
175
|
|
196
176
|
def query_workitems (criteria)
|
197
177
|
|
198
|
-
|
178
|
+
count = criteria.delete('count')
|
179
|
+
|
180
|
+
result = @dbs['workitems'].query_workitems(criteria)
|
181
|
+
|
182
|
+
count ? result.size : result.collect { |h| Ruote::Workitem.new(h) }
|
199
183
|
end
|
200
184
|
|
201
185
|
# Overwriting Ruote::StorageBase.get_msgs
|
@@ -205,9 +189,14 @@ module Couch
|
|
205
189
|
#
|
206
190
|
def get_msgs
|
207
191
|
|
192
|
+
mt = @msgs_thread
|
193
|
+
|
208
194
|
ensure_msgs_thread_is_running
|
209
195
|
|
210
196
|
msgs = []
|
197
|
+
2.times { msgs = get_many('msgs') } if mt != @msgs_thread
|
198
|
+
#
|
199
|
+
# seems necessary to avoid any msgs leak :-(
|
211
200
|
|
212
201
|
while @msgs_queue.size > 0
|
213
202
|
msgs << @msgs_queue.pop
|
@@ -234,6 +223,8 @@ module Couch
|
|
234
223
|
|
235
224
|
deleted, s = @schedules_queue.pop
|
236
225
|
|
226
|
+
next unless s
|
227
|
+
|
237
228
|
if deleted
|
238
229
|
@schedules.delete(s['_id'])
|
239
230
|
else
|
@@ -241,7 +232,7 @@ module Couch
|
|
241
232
|
end
|
242
233
|
end
|
243
234
|
|
244
|
-
filter_schedules(@schedules.values, now)
|
235
|
+
filter_schedules(@schedules.values.reject { |sch| sch['at'].nil? }, now)
|
245
236
|
end
|
246
237
|
|
247
238
|
protected
|
data/lib/ruote/couch/version.rb
CHANGED
data/ruote-couch.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ruote-couch}
|
8
|
-
s.version = "2.1.
|
8
|
+
s.version = "2.1.11"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["John Mettraux"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-10-01}
|
13
13
|
s.description = %q{CouchDB storage for ruote 2.1 (ruby workflow engine)}
|
14
14
|
s.email = %q{jmettraux@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
"CHANGELOG.txt",
|
21
|
+
"CREDITS.txt",
|
21
22
|
"LICENSE.txt",
|
22
23
|
"README.rdoc",
|
23
24
|
"Rakefile",
|
@@ -29,7 +30,6 @@ Gem::Specification.new do |s|
|
|
29
30
|
"lib/ruote/couch/version.rb",
|
30
31
|
"ruote-couch.gemspec",
|
31
32
|
"test/functional/base.rb",
|
32
|
-
"test/functional/ft_0_long_polling.rb",
|
33
33
|
"test/functional/test.rb",
|
34
34
|
"test/functional_connection.rb",
|
35
35
|
"test/test.rb",
|
@@ -51,21 +51,21 @@ Gem::Specification.new do |s|
|
|
51
51
|
s.specification_version = 3
|
52
52
|
|
53
53
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
54
|
-
s.add_runtime_dependency(%q<ruote>, [">= 2.1.
|
55
|
-
s.add_runtime_dependency(%q<rufus-jig>, [">= 0.1.
|
54
|
+
s.add_runtime_dependency(%q<ruote>, [">= 2.1.11"])
|
55
|
+
s.add_runtime_dependency(%q<rufus-jig>, [">= 0.1.23"])
|
56
56
|
s.add_development_dependency(%q<yard>, [">= 0"])
|
57
57
|
s.add_development_dependency(%q<rake>, [">= 0"])
|
58
58
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
59
59
|
else
|
60
|
-
s.add_dependency(%q<ruote>, [">= 2.1.
|
61
|
-
s.add_dependency(%q<rufus-jig>, [">= 0.1.
|
60
|
+
s.add_dependency(%q<ruote>, [">= 2.1.11"])
|
61
|
+
s.add_dependency(%q<rufus-jig>, [">= 0.1.23"])
|
62
62
|
s.add_dependency(%q<yard>, [">= 0"])
|
63
63
|
s.add_dependency(%q<rake>, [">= 0"])
|
64
64
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
65
65
|
end
|
66
66
|
else
|
67
|
-
s.add_dependency(%q<ruote>, [">= 2.1.
|
68
|
-
s.add_dependency(%q<rufus-jig>, [">= 0.1.
|
67
|
+
s.add_dependency(%q<ruote>, [">= 2.1.11"])
|
68
|
+
s.add_dependency(%q<rufus-jig>, [">= 0.1.23"])
|
69
69
|
s.add_dependency(%q<yard>, [">= 0"])
|
70
70
|
s.add_dependency(%q<rake>, [">= 0"])
|
71
71
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
@@ -9,18 +9,35 @@ require 'yajl' rescue require 'json'
|
|
9
9
|
require 'rufus-json'
|
10
10
|
Rufus::Json.detect_backend
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
unless $http_lib_loaded
|
13
|
+
begin
|
14
|
+
if ARGV.include?('--patron')
|
15
|
+
require 'patron'
|
16
|
+
puts ' : using patron'
|
17
|
+
elsif ARGV.include?('--netp')
|
18
|
+
require 'net/http/persistent'
|
19
|
+
puts ' : using net-http-persistent'
|
20
|
+
else
|
21
|
+
puts ' : using net/http'
|
22
|
+
end
|
23
|
+
rescue LoadError => le
|
24
|
+
# then use 'net/http'
|
25
|
+
puts ' : falling back to net/http'
|
26
|
+
end
|
27
|
+
$http_lib_loaded = true
|
16
28
|
end
|
17
29
|
|
18
30
|
require 'ruote/couch/storage'
|
19
31
|
|
32
|
+
def _couch_url
|
33
|
+
|
34
|
+
File.read('couch_url.txt').strip rescue 'http://127.0.0.1:5984'
|
35
|
+
end
|
36
|
+
|
20
37
|
|
21
38
|
unless $_RUOTE_COUCH_CLEANED
|
22
39
|
|
23
|
-
couch = Rufus::Jig::Couch.new(
|
40
|
+
couch = Rufus::Jig::Couch.new(_couch_url)
|
24
41
|
%w[
|
25
42
|
configurations errors expressions msgs schedules variables workitems
|
26
43
|
].each do |type|
|
@@ -36,8 +53,7 @@ def new_storage (opts)
|
|
36
53
|
opts ||= {}
|
37
54
|
|
38
55
|
Ruote::Couch::CouchStorage.new(
|
39
|
-
|
40
|
-
|
41
|
-
opts.merge!('couch_prefix' => 'test', 'couch_timeout' => 1))
|
56
|
+
_couch_url,
|
57
|
+
opts.merge!('couch_prefix' => 'test', :basic_auth => %w[ admin admin ]))
|
42
58
|
end
|
43
59
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 2
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 2.1.
|
8
|
+
- 11
|
9
|
+
version: 2.1.11
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- John Mettraux
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-10-01 00:00:00 +09:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -27,8 +27,8 @@ dependencies:
|
|
27
27
|
segments:
|
28
28
|
- 2
|
29
29
|
- 1
|
30
|
-
-
|
31
|
-
version: 2.1.
|
30
|
+
- 11
|
31
|
+
version: 2.1.11
|
32
32
|
type: :runtime
|
33
33
|
version_requirements: *id001
|
34
34
|
- !ruby/object:Gem::Dependency
|
@@ -41,8 +41,8 @@ dependencies:
|
|
41
41
|
segments:
|
42
42
|
- 0
|
43
43
|
- 1
|
44
|
-
-
|
45
|
-
version: 0.1.
|
44
|
+
- 23
|
45
|
+
version: 0.1.23
|
46
46
|
type: :runtime
|
47
47
|
version_requirements: *id002
|
48
48
|
- !ruby/object:Gem::Dependency
|
@@ -92,6 +92,7 @@ extra_rdoc_files:
|
|
92
92
|
- README.rdoc
|
93
93
|
files:
|
94
94
|
- CHANGELOG.txt
|
95
|
+
- CREDITS.txt
|
95
96
|
- LICENSE.txt
|
96
97
|
- README.rdoc
|
97
98
|
- Rakefile
|
@@ -103,7 +104,6 @@ files:
|
|
103
104
|
- lib/ruote/couch/version.rb
|
104
105
|
- ruote-couch.gemspec
|
105
106
|
- test/functional/base.rb
|
106
|
-
- test/functional/ft_0_long_polling.rb
|
107
107
|
- test/functional/test.rb
|
108
108
|
- test/functional_connection.rb
|
109
109
|
- test/test.rb
|
@@ -1,66 +0,0 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# testing ruote-couch
|
4
|
-
#
|
5
|
-
# Fri Mar 12 17:15:27 JST 2010
|
6
|
-
#
|
7
|
-
|
8
|
-
require File.join(File.dirname(__FILE__), 'base')
|
9
|
-
|
10
|
-
|
11
|
-
class FtLongPollingTest < Test::Unit::TestCase
|
12
|
-
|
13
|
-
def setup
|
14
|
-
|
15
|
-
@engine =
|
16
|
-
Ruote::Engine.new(
|
17
|
-
Ruote::Worker.new(
|
18
|
-
Ruote::Couch::CouchStorage.new(
|
19
|
-
'127.0.0.1',
|
20
|
-
5984,
|
21
|
-
'couch_prefix' => 'test', 'couch_timeout' => 2 * 60)))
|
22
|
-
end
|
23
|
-
|
24
|
-
def teardown
|
25
|
-
|
26
|
-
@engine.shutdown
|
27
|
-
@engine.context.storage.purge!
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_wait
|
31
|
-
|
32
|
-
trace = []
|
33
|
-
|
34
|
-
@engine.register_participant '.+' do |workitem|
|
35
|
-
trace << Time.now
|
36
|
-
end
|
37
|
-
|
38
|
-
pdef = Ruote.process_definition do
|
39
|
-
sequence do
|
40
|
-
alpha
|
41
|
-
wait '3m'
|
42
|
-
bravo
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
@engine.context.logger.noisy = true
|
47
|
-
|
48
|
-
wfid = @engine.launch(pdef)
|
49
|
-
|
50
|
-
sleep 15
|
51
|
-
assert_equal 1, trace.size
|
52
|
-
|
53
|
-
assert_not_nil @engine.context.storage.instance_variable_get(:@poller)
|
54
|
-
|
55
|
-
@engine.wait_for(wfid)
|
56
|
-
|
57
|
-
p trace
|
58
|
-
|
59
|
-
assert_equal 2, trace.size
|
60
|
-
|
61
|
-
delta = trace.last - trace.first
|
62
|
-
|
63
|
-
assert_in_delta 3.0 * 60, delta, 1.0
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|