baza.rb 0.10.2 → 0.11.0
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/Gemfile.lock +12 -12
- data/lib/baza-rb/version.rb +1 -1
- data/lib/baza-rb.rb +43 -41
- 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: c3f6b8fd3d4ae976677a1b3307a3c5c3279b61aae5469ffb0f113103dae1c8b5
|
4
|
+
data.tar.gz: 6954c6b824ac00e1951b6dc43cc4ee0824739f7a73370599cd4ac5a1081a885d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5eccf68db6789c2e02861917eb036c6da42970182c2d92dfbf2d1c646c193e29479e2eadc11ca1eadf1cb3ea24bdfd95397f194771496a275d2d80b9dc641f4a
|
7
|
+
data.tar.gz: d229ff82c8c01651d5dc5c46f62c4b373651624e91c8a126de8888ec098c30374fad72254c86998c4a5c5f16a9f6fb09e03c29be1fd6d0fd7f14855d64fbf6f8
|
data/Gemfile.lock
CHANGED
@@ -36,7 +36,7 @@ GEM
|
|
36
36
|
ellipsized (0.3.0)
|
37
37
|
ethon (0.15.0)
|
38
38
|
ffi (>= 1.15.0)
|
39
|
-
factbase (0.16.
|
39
|
+
factbase (0.16.7)
|
40
40
|
backtrace (~> 0.4)
|
41
41
|
decoor (~> 0.1)
|
42
42
|
ellipsized (~> 0.3)
|
@@ -65,7 +65,7 @@ GEM
|
|
65
65
|
ffi (1.17.2-x86_64-linux-gnu)
|
66
66
|
hashdiff (1.2.1)
|
67
67
|
iri (0.11.2)
|
68
|
-
json (2.
|
68
|
+
json (2.15.0)
|
69
69
|
language_server-protocol (3.17.0.5)
|
70
70
|
lint_roller (1.1.0)
|
71
71
|
logger (1.7.0)
|
@@ -83,13 +83,13 @@ GEM
|
|
83
83
|
net-http (0.6.0)
|
84
84
|
uri
|
85
85
|
nio4r (2.7.4)
|
86
|
-
nokogiri (1.18.
|
86
|
+
nokogiri (1.18.10-arm64-darwin)
|
87
87
|
racc (~> 1.4)
|
88
|
-
nokogiri (1.18.
|
88
|
+
nokogiri (1.18.10-x64-mingw-ucrt)
|
89
89
|
racc (~> 1.4)
|
90
|
-
nokogiri (1.18.
|
90
|
+
nokogiri (1.18.10-x86_64-darwin)
|
91
91
|
racc (~> 1.4)
|
92
|
-
nokogiri (1.18.
|
92
|
+
nokogiri (1.18.10-x86_64-linux-gnu)
|
93
93
|
racc (~> 1.4)
|
94
94
|
online (0.1.0)
|
95
95
|
timeout (~> 0.4)
|
@@ -99,9 +99,9 @@ GEM
|
|
99
99
|
parser (3.3.9.0)
|
100
100
|
ast (~> 2.4.1)
|
101
101
|
racc
|
102
|
-
prism (1.
|
102
|
+
prism (1.5.1)
|
103
103
|
public_suffix (6.0.2)
|
104
|
-
puma (7.0.
|
104
|
+
puma (7.0.3)
|
105
105
|
nio4r (~> 2.0)
|
106
106
|
qbash (0.4.5)
|
107
107
|
backtrace (> 0)
|
@@ -121,9 +121,9 @@ GEM
|
|
121
121
|
rack (>= 3)
|
122
122
|
rainbow (3.1.1)
|
123
123
|
rake (13.3.0)
|
124
|
-
random-port (0.7.
|
125
|
-
tago (
|
126
|
-
regexp_parser (2.11.
|
124
|
+
random-port (0.7.6)
|
125
|
+
tago (~> 0.0)
|
126
|
+
regexp_parser (2.11.3)
|
127
127
|
retries (0.0.5)
|
128
128
|
rexml (3.4.4)
|
129
129
|
rubocop (1.80.2)
|
@@ -137,7 +137,7 @@ GEM
|
|
137
137
|
rubocop-ast (>= 1.46.0, < 2.0)
|
138
138
|
ruby-progressbar (~> 1.7)
|
139
139
|
unicode-display_width (>= 2.4.0, < 4.0)
|
140
|
-
rubocop-ast (1.
|
140
|
+
rubocop-ast (1.47.1)
|
141
141
|
parser (>= 3.3.7.2)
|
142
142
|
prism (~> 1.4)
|
143
143
|
rubocop-minitest (0.38.2)
|
data/lib/baza-rb/version.rb
CHANGED
data/lib/baza-rb.rb
CHANGED
@@ -102,21 +102,21 @@ class BazaRb
|
|
102
102
|
|
103
103
|
# Push factbase to the server to create a new job.
|
104
104
|
#
|
105
|
-
# @param [String] name The unique name of the
|
105
|
+
# @param [String] name The unique name of the product on the server
|
106
106
|
# @param [String] data The binary data to push to the server (factbase content)
|
107
107
|
# @param [Array<String>] meta List of metadata strings to attach to the job
|
108
108
|
# @param [Integer] chunk_size Maximum size of one chunk
|
109
109
|
# @raise [ServerFailure] If the push operation fails
|
110
|
-
def push(
|
111
|
-
raise 'The "name" of the job is nil' if
|
112
|
-
raise 'The "name" of the job may not be empty' if
|
110
|
+
def push(pname, data, meta, chunk_size: DEFAULT_CHUNK_SIZE)
|
111
|
+
raise 'The "name" of the job is nil' if pname.nil?
|
112
|
+
raise 'The "name" of the job may not be empty' if pname.empty?
|
113
113
|
raise 'The "data" of the job is nil' if data.nil?
|
114
114
|
raise 'The "meta" of the job is nil' if meta.nil?
|
115
115
|
elapsed(@loog) do
|
116
116
|
Tempfile.open do |file|
|
117
117
|
File.binwrite(file.path, data)
|
118
118
|
upload(
|
119
|
-
home.append('push').append(
|
119
|
+
home.append('push').append(pname),
|
120
120
|
file.path,
|
121
121
|
headers.merge(
|
122
122
|
'X-Zerocracy-Meta' => meta.map { |v| Base64.encode64(v).delete("\n") }.join(' ')
|
@@ -217,41 +217,41 @@ class BazaRb
|
|
217
217
|
|
218
218
|
# Lock the name.
|
219
219
|
#
|
220
|
-
# @param [String]
|
220
|
+
# @param [String] pname The name of the product on the server
|
221
221
|
# @param [String] owner The owner of the lock (any string)
|
222
222
|
# @raise [RuntimeError] If the name is already locked
|
223
223
|
# @raise [ServerFailure] If the lock operation fails
|
224
|
-
def lock(
|
225
|
-
raise 'The "
|
226
|
-
raise 'The "
|
224
|
+
def lock(pname, owner)
|
225
|
+
raise 'The "pname" of the product is nil' if pname.nil?
|
226
|
+
raise 'The "pname" of the product may not be empty' if pname.empty?
|
227
227
|
raise 'The "owner" of the lock is nil' if owner.nil?
|
228
228
|
elapsed(@loog) do
|
229
229
|
ret = post(
|
230
|
-
home.append('lock').append(
|
230
|
+
home.append('lock').append(pname),
|
231
231
|
{ 'owner' => owner },
|
232
232
|
[302, 409]
|
233
233
|
)
|
234
|
-
throw :"
|
235
|
-
raise "Failed to lock
|
234
|
+
throw :"Product name #{pname.inspect} locked at #{@host}" if ret.code == 302
|
235
|
+
raise "Failed to lock #{pname.inspect} product at #{@host}, it's already locked"
|
236
236
|
end
|
237
237
|
end
|
238
238
|
|
239
239
|
# Unlock the name.
|
240
240
|
#
|
241
|
-
# @param [String]
|
241
|
+
# @param [String] pname The name of the job on the server
|
242
242
|
# @param [String] owner The owner of the lock (any string)
|
243
243
|
# @raise [ServerFailure] If the unlock operation fails
|
244
|
-
def unlock(
|
245
|
-
raise 'The "
|
246
|
-
raise 'The "
|
244
|
+
def unlock(pname, owner)
|
245
|
+
raise 'The "pname" of the job is nil' if pname.nil?
|
246
|
+
raise 'The "pname" of the job may not be empty' if pname.empty?
|
247
247
|
raise 'The "owner" of the lock is nil' if owner.nil?
|
248
248
|
raise 'The "owner" of the lock may not be empty' if owner.empty?
|
249
249
|
elapsed(@loog) do
|
250
250
|
post(
|
251
|
-
home.append('unlock').append(
|
251
|
+
home.append('unlock').append(pname),
|
252
252
|
{ 'owner' => owner }
|
253
253
|
)
|
254
|
-
throw :"Job name
|
254
|
+
throw :"Job name #{pname.inspect} unlocked at #{@host}"
|
255
255
|
end
|
256
256
|
end
|
257
257
|
|
@@ -274,16 +274,16 @@ class BazaRb
|
|
274
274
|
|
275
275
|
# Check whether the name of the job exists on the server.
|
276
276
|
#
|
277
|
-
# @param [String] name The name of the
|
277
|
+
# @param [String] name The name of the product on the server
|
278
278
|
# @return [Boolean] TRUE if such name exists
|
279
|
-
def name_exists?(
|
280
|
-
raise 'The "
|
281
|
-
raise 'The "
|
279
|
+
def name_exists?(pname)
|
280
|
+
raise 'The "pname" of the product is nil' if pname.nil?
|
281
|
+
raise 'The "pname" of the product may not be empty' if pname.empty?
|
282
282
|
exists = false
|
283
283
|
elapsed(@loog) do
|
284
|
-
ret = get(home.append('exists').append(
|
284
|
+
ret = get(home.append('exists').append(pname))
|
285
285
|
exists = ret.body == 'yes'
|
286
|
-
throw :"The name
|
286
|
+
throw :"The name #{pname.inspect} #{exists ? 'exists' : "doesn't exist"} at #{@host}"
|
287
287
|
end
|
288
288
|
exists
|
289
289
|
end
|
@@ -295,13 +295,13 @@ class BazaRb
|
|
295
295
|
# ignored. It is expected to use only small placeholder files, not real
|
296
296
|
# data.
|
297
297
|
#
|
298
|
-
# @param [String]
|
298
|
+
# @param [String] pname The name of the product on the server
|
299
299
|
# @param [String] file The path to the file to upload
|
300
300
|
# @return [Integer] The ID of the created durable
|
301
301
|
# @raise [ServerFailure] If the upload fails
|
302
|
-
def durable_place(
|
303
|
-
raise 'The "
|
304
|
-
raise 'The "
|
302
|
+
def durable_place(pname, file)
|
303
|
+
raise 'The "pname" of the durable is nil' if pname.nil?
|
304
|
+
raise 'The "pname" of the durable may not be empty' if pname.empty?
|
305
305
|
raise 'The "file" of the durable is nil' if file.nil?
|
306
306
|
raise "The file '#{file}' is absent" unless File.exist?(file)
|
307
307
|
if File.size(file) > 1024
|
@@ -312,13 +312,14 @@ class BazaRb
|
|
312
312
|
ret = post(
|
313
313
|
home.append('durables').append('place'),
|
314
314
|
{
|
315
|
-
'
|
315
|
+
'pname' => pname,
|
316
|
+
'jname' => pname,
|
316
317
|
'file' => File.basename(file),
|
317
318
|
'zip' => File.open(file, 'rb')
|
318
319
|
}
|
319
320
|
)
|
320
321
|
id = ret.headers['X-Zerocracy-DurableId'].to_i
|
321
|
-
throw :"Durable ##{id} (#{file}, #{File.size(file)} bytes) placed for job \"#{
|
322
|
+
throw :"Durable ##{id} (#{file}, #{File.size(file)} bytes) placed for job \"#{pname}\" at #{@host}"
|
322
323
|
end
|
323
324
|
id
|
324
325
|
end
|
@@ -399,22 +400,22 @@ class BazaRb
|
|
399
400
|
|
400
401
|
# Find a durable by job name and file name.
|
401
402
|
#
|
402
|
-
# @param [String]
|
403
|
+
# @param [String] pname The name of the job
|
403
404
|
# @param [String] file The file name
|
404
405
|
# @return [Integer, nil] The ID of the durable if found, nil if not found
|
405
|
-
def durable_find(
|
406
|
-
raise 'The "
|
407
|
-
raise 'The "
|
406
|
+
def durable_find(pname, file)
|
407
|
+
raise 'The "pname" is nil' if pname.nil?
|
408
|
+
raise 'The "pname" may not be empty' if pname.empty?
|
408
409
|
raise 'The "file" is nil' if file.nil?
|
409
410
|
raise 'The "file" may not be empty' if file.empty?
|
410
411
|
id = nil
|
411
412
|
elapsed(@loog) do
|
412
|
-
ret = get(home.append('durables').append('find').add(jname:, file:), [200, 404])
|
413
|
+
ret = get(home.append('durables').append('find').add(jname: pname, pname:, file:), [200, 404])
|
413
414
|
if ret.code == 200
|
414
415
|
id = ret.body.to_i
|
415
|
-
throw :"Found durable ##{id} for job \"#{
|
416
|
+
throw :"Found durable ##{id} for job \"#{pname}\" file \"#{file}\" at #{@host}"
|
416
417
|
else
|
417
|
-
throw :"Durable not found for job \"#{
|
418
|
+
throw :"Durable not found for job \"#{pname}\" file \"#{file}\" at #{@host}"
|
418
419
|
end
|
419
420
|
end
|
420
421
|
id
|
@@ -530,15 +531,15 @@ class BazaRb
|
|
530
531
|
# for the given badge already exists, it's returned. Otherwise, the block
|
531
532
|
# is executed and its result is cached.
|
532
533
|
#
|
533
|
-
# @param [String] name Name of the
|
534
|
+
# @param [String] name Name of the product
|
534
535
|
# @param [String] badge Unique identifier for this valve/computation
|
535
536
|
# @param [String] why The reason/description for entering this valve
|
536
537
|
# @param [nil|Integer] job Optional job ID to associate with this valve
|
537
538
|
# @yield Block that computes the result if not cached
|
538
539
|
# @return [String] The cached result or newly computed result from the block
|
539
540
|
# @raise [ServerFailure] If the valve operation fails
|
540
|
-
def enter(
|
541
|
-
elapsed(@loog, good: "Entered valve #{badge} to #{
|
541
|
+
def enter(pname, badge, why, job)
|
542
|
+
elapsed(@loog, good: "Entered valve #{badge} to #{pname}") do
|
542
543
|
retry_it do
|
543
544
|
ret = get(home.append('valves').append('result').add(badge:), [200, 204])
|
544
545
|
return ret.body if ret.code == 200
|
@@ -548,7 +549,8 @@ class BazaRb
|
|
548
549
|
post(
|
549
550
|
uri,
|
550
551
|
{
|
551
|
-
'name' =>
|
552
|
+
'name' => pname,
|
553
|
+
'pname' => pname,
|
552
554
|
'badge' => badge,
|
553
555
|
'why' => why,
|
554
556
|
'result' => r.to_s
|