cloudi 2.0.4 → 2.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.markdown +1 -1
- data/lib/cloudi.rb +83 -37
- data.tar.gz.sig +0 -0
- metadata +28 -28
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c215eeae654dce44290b1d2429d205978668b013e66f421c667b2e21966432da
|
4
|
+
data.tar.gz: e888c9c3acffc6ba370e014fe0a263932b421be0456876ae69499f99af1e1775
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccb87d7df1269f529979319aae3efea2c3b33667b1cee73f1febf46937f095fa0c222c20503d6d1c3e263bc01ee22163157547690ea06e6904e5ff5373b1e79c
|
7
|
+
data.tar.gz: 78589425efc100a8c3f558f4e74f89d737321d2e7bdcb7e952cf0e96d89f3b00650c5c51510a7fb71a3ed364e615353861a02be45c281c4540091b1c25f7f723
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.markdown
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
`cloudi_api_ruby`
|
2
2
|
=================
|
3
3
|
|
4
|
-
[![Build Status](https://travis-ci.
|
4
|
+
[![Build Status](https://app.travis-ci.com/CloudI/cloudi_api_ruby.svg?branch=master)](https://app.travis-ci.com/CloudI/cloudi_api_ruby)
|
5
5
|
[![Gem Package Version](https://img.shields.io/gem/v/cloudi.svg?maxAge=2592000)](https://rubygems.org/gems/cloudi)
|
6
6
|
|
7
7
|
Ruby [CloudI API](https://cloudi.org/api.html#1_Intro)
|
data/lib/cloudi.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
#
|
5
5
|
# MIT License
|
6
6
|
#
|
7
|
-
# Copyright (c) 2011-
|
7
|
+
# Copyright (c) 2011-2023 Michael Truog <mjtruog at protonmail dot com>
|
8
8
|
#
|
9
9
|
# Permission is hereby granted, free of charge, to any person obtaining a
|
10
10
|
# copy of this software and associated documentation files (the "Software"),
|
@@ -43,7 +43,7 @@ module CloudI
|
|
43
43
|
|
44
44
|
def initialize(thread_index)
|
45
45
|
protocol = API.getenv('CLOUDI_API_INIT_PROTOCOL')
|
46
|
-
|
46
|
+
buffer_size = API.getenv_to_uint('CLOUDI_API_INIT_BUFFER_SIZE')
|
47
47
|
if protocol == 'tcp'
|
48
48
|
@s = IO.for_fd(thread_index + 3, File::RDWR, autoclose: false)
|
49
49
|
@s.sync = true
|
@@ -62,7 +62,7 @@ module CloudI
|
|
62
62
|
end
|
63
63
|
@initialization_complete = false
|
64
64
|
@terminate = false
|
65
|
-
@size =
|
65
|
+
@size = buffer_size
|
66
66
|
@callbacks = Hash.new
|
67
67
|
@timeout_terminate = 10 # TIMEOUT_TERMINATE_MIN
|
68
68
|
send(Erlang.term_to_binary(:init))
|
@@ -80,8 +80,7 @@ module CloudI
|
|
80
80
|
attr_reader :priority_default
|
81
81
|
|
82
82
|
def self.thread_count
|
83
|
-
|
84
|
-
s.to_i
|
83
|
+
return API.getenv_to_uint('CLOUDI_API_INIT_THREAD_COUNT')
|
85
84
|
end
|
86
85
|
|
87
86
|
def subscribe(pattern, function)
|
@@ -166,66 +165,70 @@ module CloudI
|
|
166
165
|
end
|
167
166
|
|
168
167
|
def forward_(request_type, name, request_info, request,
|
169
|
-
timeout, priority, trans_id,
|
168
|
+
timeout, priority, trans_id, source)
|
170
169
|
case request_type
|
171
170
|
when ASYNC
|
172
171
|
forward_async(name, request_info, request,
|
173
|
-
timeout, priority, trans_id,
|
172
|
+
timeout, priority, trans_id, source)
|
174
173
|
when SYNC
|
175
174
|
forward_sync(name, request_info, request,
|
176
|
-
timeout, priority, trans_id,
|
175
|
+
timeout, priority, trans_id, source)
|
177
176
|
end
|
178
177
|
end
|
179
178
|
|
180
179
|
def forward_async(name, request_info, request,
|
181
|
-
timeout, priority, trans_id,
|
180
|
+
timeout, priority, trans_id, source)
|
182
181
|
send(Erlang.term_to_binary([:forward_async, name,
|
183
182
|
OtpErlangBinary.new(request_info),
|
184
183
|
OtpErlangBinary.new(request),
|
185
184
|
timeout, priority,
|
186
|
-
OtpErlangBinary.new(trans_id),
|
185
|
+
OtpErlangBinary.new(trans_id),
|
186
|
+
source]))
|
187
187
|
raise ForwardAsyncException
|
188
188
|
end
|
189
189
|
|
190
190
|
def forward_sync(name, request_info, request,
|
191
|
-
timeout, priority, trans_id,
|
191
|
+
timeout, priority, trans_id, source)
|
192
192
|
send(Erlang.term_to_binary([:forward_sync, name,
|
193
193
|
OtpErlangBinary.new(request_info),
|
194
194
|
OtpErlangBinary.new(request),
|
195
195
|
timeout, priority,
|
196
|
-
OtpErlangBinary.new(trans_id),
|
196
|
+
OtpErlangBinary.new(trans_id),
|
197
|
+
source]))
|
197
198
|
raise ForwardSyncException
|
198
199
|
end
|
199
200
|
|
200
201
|
def return_(request_type, name, pattern, response_info, response,
|
201
|
-
timeout, trans_id,
|
202
|
+
timeout, trans_id, source)
|
202
203
|
case request_type
|
203
204
|
when ASYNC
|
204
205
|
return_async(name, pattern, response_info, response,
|
205
|
-
timeout, trans_id,
|
206
|
+
timeout, trans_id, source)
|
206
207
|
when SYNC
|
207
208
|
return_sync(name, pattern, response_info, response,
|
208
|
-
timeout, trans_id,
|
209
|
+
timeout, trans_id, source)
|
209
210
|
end
|
210
211
|
end
|
211
212
|
|
212
213
|
def return_async(name, pattern, response_info, response,
|
213
|
-
timeout, trans_id,
|
214
|
+
timeout, trans_id, source)
|
214
215
|
send(Erlang.term_to_binary([:return_async, name, pattern,
|
215
216
|
OtpErlangBinary.new(response_info),
|
216
217
|
OtpErlangBinary.new(response),
|
217
218
|
timeout,
|
218
|
-
OtpErlangBinary.new(trans_id),
|
219
|
+
OtpErlangBinary.new(trans_id),
|
220
|
+
source]))
|
219
221
|
raise ReturnAsyncException
|
220
222
|
end
|
221
223
|
|
222
224
|
def return_sync(name, pattern, response_info, response,
|
223
|
-
timeout, trans_id,
|
225
|
+
timeout, trans_id, source)
|
224
226
|
send(Erlang.term_to_binary([:return_sync, name, pattern,
|
225
227
|
OtpErlangBinary.new(response_info),
|
226
228
|
OtpErlangBinary.new(response),
|
227
229
|
timeout,
|
228
|
-
OtpErlangBinary.new(trans_id),
|
230
|
+
OtpErlangBinary.new(trans_id),
|
231
|
+
source]))
|
229
232
|
raise ReturnSyncException
|
230
233
|
end
|
231
234
|
|
@@ -242,13 +245,33 @@ module CloudI
|
|
242
245
|
return poll_request(nil, false)
|
243
246
|
end
|
244
247
|
|
248
|
+
def self.process_index_
|
249
|
+
return API.getenv_to_uint('CLOUDI_API_INIT_PROCESS_INDEX')
|
250
|
+
end
|
251
|
+
|
252
|
+
def self.process_count_max_
|
253
|
+
return API.getenv_to_uint('CLOUDI_API_INIT_PROCESS_COUNT_MAX')
|
254
|
+
end
|
255
|
+
|
256
|
+
def self.process_count_min_
|
257
|
+
return API.getenv_to_uint('CLOUDI_API_INIT_PROCESS_COUNT_MIN')
|
258
|
+
end
|
259
|
+
|
260
|
+
def self.timeout_initialize_
|
261
|
+
return API.getenv_to_uint('CLOUDI_API_INIT_TIMEOUT_INITIALIZE')
|
262
|
+
end
|
263
|
+
|
264
|
+
def self.timeout_terminate_
|
265
|
+
return API.getenv_to_uint('CLOUDI_API_INIT_TIMEOUT_TERMINATE')
|
266
|
+
end
|
267
|
+
|
245
268
|
def null_response(request_type, name, pattern, request_info, request,
|
246
|
-
timeout, priority, trans_id,
|
269
|
+
timeout, priority, trans_id, source)
|
247
270
|
return ''
|
248
271
|
end
|
249
272
|
|
250
273
|
def callback(command, name, pattern, request_info, request,
|
251
|
-
timeout, priority, trans_id,
|
274
|
+
timeout, priority, trans_id, source)
|
252
275
|
function_queue = @callbacks.fetch(pattern, nil)
|
253
276
|
if function_queue.nil?
|
254
277
|
function = method(:null_response)
|
@@ -262,7 +285,8 @@ module CloudI
|
|
262
285
|
begin
|
263
286
|
response = function.call(ASYNC, name, pattern,
|
264
287
|
request_info, request,
|
265
|
-
timeout, priority,
|
288
|
+
timeout, priority,
|
289
|
+
trans_id, source)
|
266
290
|
if response.kind_of?(Array)
|
267
291
|
API.assert{response.length == 2}
|
268
292
|
response_info = response[0]
|
@@ -296,9 +320,12 @@ module CloudI
|
|
296
320
|
$stderr.puts e.backtrace
|
297
321
|
return
|
298
322
|
rescue StandardError => e
|
299
|
-
return_null_response = true
|
300
323
|
$stderr.puts e.message
|
301
324
|
$stderr.puts e.backtrace
|
325
|
+
if @fatal_exceptions
|
326
|
+
exit(1)
|
327
|
+
end
|
328
|
+
return_null_response = true
|
302
329
|
rescue SystemExit => e
|
303
330
|
$stderr.puts e.message
|
304
331
|
$stderr.puts e.backtrace
|
@@ -314,14 +341,15 @@ module CloudI
|
|
314
341
|
end
|
315
342
|
begin
|
316
343
|
return_async(name, pattern, response_info, response,
|
317
|
-
timeout, trans_id,
|
344
|
+
timeout, trans_id, source)
|
318
345
|
rescue ReturnAsyncException
|
319
346
|
end
|
320
347
|
when MESSAGE_SEND_SYNC
|
321
348
|
begin
|
322
349
|
response = function.call(SYNC, name, pattern,
|
323
350
|
request_info, request,
|
324
|
-
timeout, priority,
|
351
|
+
timeout, priority,
|
352
|
+
trans_id, source)
|
325
353
|
if response.kind_of?(Array)
|
326
354
|
API.assert{response.length == 2}
|
327
355
|
response_info = response[0]
|
@@ -355,9 +383,12 @@ module CloudI
|
|
355
383
|
$stderr.puts e.backtrace
|
356
384
|
return
|
357
385
|
rescue StandardError => e
|
358
|
-
return_null_response = true
|
359
386
|
$stderr.puts e.message
|
360
387
|
$stderr.puts e.backtrace
|
388
|
+
if @fatal_exceptions
|
389
|
+
exit(1)
|
390
|
+
end
|
391
|
+
return_null_response = true
|
361
392
|
rescue SystemExit => e
|
362
393
|
$stderr.puts e.message
|
363
394
|
$stderr.puts e.backtrace
|
@@ -373,7 +404,7 @@ module CloudI
|
|
373
404
|
end
|
374
405
|
begin
|
375
406
|
return_sync(name, pattern, response_info, response,
|
376
|
-
timeout, trans_id,
|
407
|
+
timeout, trans_id, source)
|
377
408
|
rescue ReturnSyncException
|
378
409
|
end
|
379
410
|
else
|
@@ -401,12 +432,13 @@ module CloudI
|
|
401
432
|
raise TerminateException.new(@timeout_terminate)
|
402
433
|
end
|
403
434
|
when MESSAGE_REINIT
|
404
|
-
i += j; j = 4 + 4 + 4 + 1
|
405
|
-
tmp = data[i, j].unpack("
|
435
|
+
i += j; j = 4 + 4 + 4 + 1 + 1
|
436
|
+
tmp = data[i, j].unpack("LLLcC")
|
406
437
|
@process_count = tmp[0]
|
407
438
|
@timeout_async = tmp[1]
|
408
439
|
@timeout_sync = tmp[2]
|
409
440
|
@priority_default = tmp[3]
|
441
|
+
@fatal_exceptions = tmp[4]
|
410
442
|
i += j
|
411
443
|
when MESSAGE_KEEPALIVE
|
412
444
|
send(Erlang.term_to_binary(:keepalive))
|
@@ -471,14 +503,19 @@ module CloudI
|
|
471
503
|
@process_count_max = tmp[2]
|
472
504
|
@process_count_min = tmp[3]
|
473
505
|
prefix_size = tmp[4]
|
474
|
-
i += j; j = prefix_size + 4 + 4 + 4 + 4 + 1
|
475
|
-
tmp = data[i, j].unpack("Z#{prefix_size}
|
506
|
+
i += j; j = prefix_size + 4 + 4 + 4 + 4 + 1 + 1 + 4
|
507
|
+
tmp = data[i, j].unpack("Z#{prefix_size}LLLLcCl")
|
476
508
|
@prefix = tmp[0]
|
477
509
|
@timeout_initialize = tmp[1]
|
478
510
|
@timeout_async = tmp[2]
|
479
511
|
@timeout_sync = tmp[3]
|
480
512
|
@timeout_terminate = tmp[4]
|
481
513
|
@priority_default = tmp[5]
|
514
|
+
@fatal_exceptions = tmp[6]
|
515
|
+
bind = tmp[7]
|
516
|
+
if bind >= 0 then
|
517
|
+
raise InvalidInputException
|
518
|
+
end
|
482
519
|
i += j
|
483
520
|
if i != data_size
|
484
521
|
API.assert{external == false}
|
@@ -506,9 +543,9 @@ module CloudI
|
|
506
543
|
request_timeout = tmp[1]
|
507
544
|
priority = tmp[2]
|
508
545
|
trans_id = tmp[3]
|
509
|
-
|
510
|
-
i += j; j =
|
511
|
-
|
546
|
+
source_size = tmp[4]
|
547
|
+
i += j; j = source_size
|
548
|
+
source = data[i, j]
|
512
549
|
i += j
|
513
550
|
if i != data_size
|
514
551
|
API.assert{external == true}
|
@@ -519,7 +556,7 @@ module CloudI
|
|
519
556
|
data.clear()
|
520
557
|
callback(command, name, pattern, request_info, request,
|
521
558
|
request_timeout, priority, trans_id,
|
522
|
-
Erlang.binary_to_term(
|
559
|
+
Erlang.binary_to_term(source))
|
523
560
|
if @terminate
|
524
561
|
return false
|
525
562
|
end
|
@@ -575,12 +612,13 @@ module CloudI
|
|
575
612
|
end
|
576
613
|
API.assert{false}
|
577
614
|
when MESSAGE_REINIT
|
578
|
-
i += j; j = 4 + 4 + 4 + 1
|
579
|
-
tmp = data[i, j].unpack("
|
615
|
+
i += j; j = 4 + 4 + 4 + 1 + 1
|
616
|
+
tmp = data[i, j].unpack("LLLcC")
|
580
617
|
@process_count = tmp[0]
|
581
618
|
@timeout_async = tmp[1]
|
582
619
|
@timeout_sync = tmp[2]
|
583
620
|
@priority_default = tmp[3]
|
621
|
+
@fatal_exceptions = tmp[4]
|
584
622
|
i += j; j = 4
|
585
623
|
if i == data_size
|
586
624
|
data.clear()
|
@@ -765,6 +803,14 @@ module CloudI
|
|
765
803
|
def self.getenv(key)
|
766
804
|
ENV[key] or raise InvalidInputException
|
767
805
|
end
|
806
|
+
|
807
|
+
def self.getenv_to_uint(name)
|
808
|
+
value = API.getenv(name).to_i
|
809
|
+
if value < 0 then
|
810
|
+
raise InvalidInputException
|
811
|
+
end
|
812
|
+
return value
|
813
|
+
end
|
768
814
|
end
|
769
815
|
|
770
816
|
class InvalidInputException < Exception
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Truog
|
@@ -11,30 +11,30 @@ cert_chain:
|
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
13
|
MIIESDCCArCgAwIBAgIBATANBgkqhkiG9w0BAQsFADAnMSUwIwYDVQQDDBxtanRy
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
14
|
+
dW9nL0RDPXByb3Rvbm1haWwvREM9Y29tMB4XDTIyMTAxMjIwMDU0MloXDTIzMTAx
|
15
|
+
MjIwMDU0MlowJzElMCMGA1UEAwwcbWp0cnVvZy9EQz1wcm90b25tYWlsL0RDPWNv
|
16
|
+
bTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBAL9nIaNAY7hDthCtaBzd
|
17
|
+
KhqiT5DXoVMqM/ya+Y676+M6WnUcqvsCJ3XvE0axG/0u0jAbu0XejTZ2/9NcETHf
|
18
|
+
N4T2bw7jA6Vnn+rN2gKk62KlEzQVxZN+zbNme6fsxQ6j+nc4kqB6s6pd8VdTElJz
|
19
|
+
goBHUm/wmFRIpcbd+MZRQz+OJASi7Swjx+r65cFG7Ik7BriTnJLoAnrso1dfAYCV
|
20
|
+
ptrn+OMq33MFKkxneu7FrZsaD7Qo0taKl7nenZmG+qCzvJfiprzMyE1JDGPJptmf
|
21
|
+
VpjCct+Zolwa1MS+W07VS09iSllQ2xQPjSeMkrjKmjss3+kig4oKYTRP6gpdbWd7
|
22
|
+
hWIn/h2mQ3OmGeAlq6rcN0p9PVTYTByRT773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39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: erlang_rb
|
@@ -45,7 +45,7 @@ dependencies:
|
|
45
45
|
version: '2.0'
|
46
46
|
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 2.0.
|
48
|
+
version: 2.0.6
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -55,7 +55,7 @@ dependencies:
|
|
55
55
|
version: '2.0'
|
56
56
|
- - ">="
|
57
57
|
- !ruby/object:Gem::Version
|
58
|
-
version: 2.0.
|
58
|
+
version: 2.0.6
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: erlang_rb
|
61
61
|
requirement: !ruby/object:Gem::Requirement
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '2.0'
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.0.
|
68
|
+
version: 2.0.6
|
69
69
|
type: :development
|
70
70
|
prerelease: false
|
71
71
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -75,7 +75,7 @@ dependencies:
|
|
75
75
|
version: '2.0'
|
76
76
|
- - ">="
|
77
77
|
- !ruby/object:Gem::Version
|
78
|
-
version: 2.0.
|
78
|
+
version: 2.0.6
|
79
79
|
description: Ruby CloudI API
|
80
80
|
email: mjtruog@protonmail.com
|
81
81
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|