baza.rb 0.0.5 → 0.0.6
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.
- checksums.yaml +4 -4
- data/lib/baza-rb/version.rb +1 -1
- data/lib/baza-rb.rb +48 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e5d99494e1d40acfbb4e3528aa78da5c6f3db987d2a5adeef6e3b549dd7d39a
|
4
|
+
data.tar.gz: 935c8d8a3c2b91c75a9a65ff842661e21f2e6deeaa91349645a28970ad589011
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a173d77d88af5c4c5c8d82ad6ec4a19d169a9759d1fe6c5a7932d2e3a222ca496c37b83a8158175f5f7a562b94c12c3572f22e9d66e65eb822b6ab75899ab9c5
|
7
|
+
data.tar.gz: 2ca69ab0a36e5fa0a52592a7873fe115ea079df503797b2d2cba64e4bd402952a5ac3a9ea7a4ffca5edc70d40cbcfd80c518d6261a70a2ce36506d49e28d1b60
|
data/lib/baza-rb/version.rb
CHANGED
data/lib/baza-rb.rb
CHANGED
@@ -55,6 +55,10 @@ class BazaRb
|
|
55
55
|
# @param [Array<String>] meta List of metas, possibly empty
|
56
56
|
# @return [Integer] Job ID on the server
|
57
57
|
def push(name, data, meta)
|
58
|
+
raise 'The "name" of the job is nil' if name.nil?
|
59
|
+
raise 'The "name" of the job may not be empty' if name.empty?
|
60
|
+
raise 'The "data" of the job is nil' if data.nil?
|
61
|
+
raise 'The "meta" of the job is nil' if meta.nil?
|
58
62
|
id = 0
|
59
63
|
hdrs = headers.merge(
|
60
64
|
'Content-Type' => 'application/octet-stream',
|
@@ -89,6 +93,8 @@ class BazaRb
|
|
89
93
|
# @param [Integer] id The ID of the job on the server
|
90
94
|
# @return [Bytes] Binary data pulled
|
91
95
|
def pull(id)
|
96
|
+
raise 'The ID of the job is nil' if id.nil?
|
97
|
+
raise 'The ID of the job must be a positive integer' unless id.positive?
|
92
98
|
data = 0
|
93
99
|
elapsed(@loog) do
|
94
100
|
Tempfile.open do |file|
|
@@ -121,6 +127,8 @@ class BazaRb
|
|
121
127
|
# @param [Integer] id The ID of the job on the server
|
122
128
|
# @return [Boolean] TRUE if the job is already finished
|
123
129
|
def finished?(id)
|
130
|
+
raise 'The ID of the job is nil' if id.nil?
|
131
|
+
raise 'The ID of the job must be a positive integer' unless id.positive?
|
124
132
|
finished = false
|
125
133
|
elapsed(@loog) do
|
126
134
|
ret =
|
@@ -142,6 +150,8 @@ class BazaRb
|
|
142
150
|
# @param [Integer] id The ID of the job on the server
|
143
151
|
# @return [String] The stdout, as a text
|
144
152
|
def stdout(id)
|
153
|
+
raise 'The ID of the job is nil' if id.nil?
|
154
|
+
raise 'The ID of the job must be a positive integer' unless id.positive?
|
145
155
|
stdout = ''
|
146
156
|
elapsed(@loog) do
|
147
157
|
ret =
|
@@ -163,6 +173,8 @@ class BazaRb
|
|
163
173
|
# @param [Integer] id The ID of the job on the server
|
164
174
|
# @return [Integer] The exit code
|
165
175
|
def exit_code(id)
|
176
|
+
raise 'The ID of the job is nil' if id.nil?
|
177
|
+
raise 'The ID of the job must be a positive integer' unless id.positive?
|
166
178
|
code = 0
|
167
179
|
elapsed(@loog) do
|
168
180
|
ret =
|
@@ -184,6 +196,8 @@ class BazaRb
|
|
184
196
|
# @param [Integer] id The ID of the job on the server
|
185
197
|
# @return [String] The verdict
|
186
198
|
def verified(id)
|
199
|
+
raise 'The ID of the job is nil' if id.nil?
|
200
|
+
raise 'The ID of the job must be a positive integer' unless id.positive?
|
187
201
|
verdict = 0
|
188
202
|
elapsed(@loog) do
|
189
203
|
ret =
|
@@ -205,6 +219,9 @@ class BazaRb
|
|
205
219
|
# @param [String] name The name of the job on the server
|
206
220
|
# @param [String] owner The owner of the lock (any string)
|
207
221
|
def lock(name, owner)
|
222
|
+
raise 'The "name" of the job is nil' if name.nil?
|
223
|
+
raise 'The "name" of the job may not be empty' if name.empty?
|
224
|
+
raise 'The "owner" of the lock is nil' if owner.nil?
|
208
225
|
elapsed(@loog) do
|
209
226
|
with_retries(max_tries: @retries) do
|
210
227
|
checked(
|
@@ -223,6 +240,9 @@ class BazaRb
|
|
223
240
|
# @param [String] name The name of the job on the server
|
224
241
|
# @param [String] owner The owner of the lock (any string)
|
225
242
|
def unlock(name, owner)
|
243
|
+
raise 'The "name" of the job is nil' if name.nil?
|
244
|
+
raise 'The "name" of the job may not be empty' if name.empty?
|
245
|
+
raise 'The "owner" of the lock is nil' if owner.nil?
|
226
246
|
elapsed(@loog) do
|
227
247
|
with_retries(max_tries: @retries) do
|
228
248
|
checked(
|
@@ -241,6 +261,8 @@ class BazaRb
|
|
241
261
|
# @param [String] name The name of the job on the server
|
242
262
|
# @return [Integer] The ID of the job on the server
|
243
263
|
def recent(name)
|
264
|
+
raise 'The "name" of the job is nil' if name.nil?
|
265
|
+
raise 'The "name" of the job may not be empty' if name.empty?
|
244
266
|
job = 0
|
245
267
|
elapsed(@loog) do
|
246
268
|
ret =
|
@@ -262,6 +284,8 @@ class BazaRb
|
|
262
284
|
# @param [String] name The name of the job on the server
|
263
285
|
# @return [Boolean] TRUE if such name exists
|
264
286
|
def name_exists?(name)
|
287
|
+
raise 'The "name" of the job is nil' if name.nil?
|
288
|
+
raise 'The "name" of the job may not be empty' if name.empty?
|
265
289
|
exists = 0
|
266
290
|
elapsed(@loog) do
|
267
291
|
ret =
|
@@ -283,7 +307,10 @@ class BazaRb
|
|
283
307
|
# @param [String] jname The name of the job on the server
|
284
308
|
# @param [String] file The file name
|
285
309
|
def durable_place(jname, file)
|
286
|
-
raise "
|
310
|
+
raise 'The "jname" of the durable is nil' if jname.nil?
|
311
|
+
raise 'The "jname" of the durable may not be empty' if jname.empty?
|
312
|
+
raise 'The "file" of the durable is nil' if file.nil?
|
313
|
+
raise "The file '#{file}' is absent" unless File.exist?(file)
|
287
314
|
id = nil
|
288
315
|
elapsed(@loog) do
|
289
316
|
ret =
|
@@ -313,7 +340,10 @@ class BazaRb
|
|
313
340
|
# @param [Integer] id The ID of the durable
|
314
341
|
# @param [String] file The file to upload
|
315
342
|
def durable_save(id, file)
|
316
|
-
raise
|
343
|
+
raise 'The ID of the durable is nil' if id.nil?
|
344
|
+
raise 'The ID of the durable must be a positive integer' unless id.positive?
|
345
|
+
raise 'The "file" of the durable is nil' if file.nil?
|
346
|
+
raise "The file '#{file}' is absent" unless File.exist?(file)
|
317
347
|
elapsed(@loog) do
|
318
348
|
with_retries(max_tries: @retries) do
|
319
349
|
checked(
|
@@ -334,6 +364,9 @@ class BazaRb
|
|
334
364
|
# @param [Integer] id The ID of the durable
|
335
365
|
# @param [String] file The file to upload
|
336
366
|
def durable_load(id, file)
|
367
|
+
raise 'The ID of the durable is nil' if id.nil?
|
368
|
+
raise 'The ID of the durable must be a positive integer' unless id.positive?
|
369
|
+
raise 'The "file" of the durable is nil' if file.nil?
|
337
370
|
FileUtils.mkdir_p(File.dirname(file))
|
338
371
|
elapsed(@loog) do
|
339
372
|
File.open(file, 'wb') do |f|
|
@@ -362,6 +395,10 @@ class BazaRb
|
|
362
395
|
# @param [Integer] id The ID of the durable
|
363
396
|
# @param [String] owner The owner of the lock
|
364
397
|
def durable_lock(id, owner)
|
398
|
+
raise 'The ID of the durable is nil' if id.nil?
|
399
|
+
raise 'The ID of the durable must be a positive integer' unless id.positive?
|
400
|
+
raise 'The "owner" of the lock is nil' if owner.nil?
|
401
|
+
raise 'The "owner" of the lock may not be empty' if owner.empty?
|
365
402
|
elapsed(@loog) do
|
366
403
|
with_retries(max_tries: @retries) do
|
367
404
|
checked(
|
@@ -380,6 +417,10 @@ class BazaRb
|
|
380
417
|
# @param [Integer] id The ID of the durable
|
381
418
|
# @param [String] owner The owner of the lock
|
382
419
|
def durable_unlock(id, owner)
|
420
|
+
raise 'The ID of the durable is nil' if id.nil?
|
421
|
+
raise 'The ID of the durable must be a positive integer' unless id.positive?
|
422
|
+
raise 'The "owner" of the lock is nil' if owner.nil?
|
423
|
+
raise 'The "owner" of the lock may not be empty' if owner.empty?
|
383
424
|
elapsed(@loog) do
|
384
425
|
with_retries(max_tries: @retries) do
|
385
426
|
checked(
|
@@ -449,7 +490,11 @@ class BazaRb
|
|
449
490
|
allowed = [allowed] unless allowed.is_a?(Array)
|
450
491
|
mtd = (ret.request.original_options[:method] || '???').upcase
|
451
492
|
url = ret.effective_url
|
452
|
-
|
493
|
+
if ret.return_code == :operation_timedout
|
494
|
+
msg = "#{mtd} #{url} timed out in #{ret.total_time}s"
|
495
|
+
@loog.debug(msg)
|
496
|
+
raise msg
|
497
|
+
end
|
453
498
|
log = "#{mtd} #{url} -> #{ret.code} (#{format('%0.2f', ret.total_time)}s)"
|
454
499
|
if allowed.include?(ret.code)
|
455
500
|
@loog.debug(log)
|
@@ -457,7 +502,6 @@ class BazaRb
|
|
457
502
|
end
|
458
503
|
@loog.debug("#{log}\n #{(ret.headers || {}).map { |k, v| "#{k}: #{v}" }.join("\n ")}")
|
459
504
|
headers = ret.headers || {}
|
460
|
-
p ret
|
461
505
|
msg = [
|
462
506
|
"Invalid response code ##{ret.code} ",
|
463
507
|
"at #{mtd} #{url}",
|