cloudi 1.3.3 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/lib/cloudi.rb +81 -42
- metadata +78 -63
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/cloudi.rb
CHANGED
@@ -78,7 +78,7 @@ module CloudI
|
|
78
78
|
@callbacks = Hash.new
|
79
79
|
@timeout_terminate = 1000 # TIMEOUT_TERMINATE_MIN
|
80
80
|
send(Erlang.term_to_binary(:init))
|
81
|
-
poll_request(false)
|
81
|
+
poll_request(nil, false)
|
82
82
|
end
|
83
83
|
attr_reader :process_index
|
84
84
|
attr_reader :process_count
|
@@ -108,7 +108,7 @@ module CloudI
|
|
108
108
|
|
109
109
|
def subscribe_count(pattern)
|
110
110
|
send(Erlang.term_to_binary([:subscribe_count, pattern]))
|
111
|
-
return poll_request(false)
|
111
|
+
return poll_request(nil, false)
|
112
112
|
end
|
113
113
|
|
114
114
|
def unsubscribe(pattern)
|
@@ -137,7 +137,7 @@ module CloudI
|
|
137
137
|
OtpErlangBinary.new(request_info),
|
138
138
|
OtpErlangBinary.new(request),
|
139
139
|
timeout, priority]))
|
140
|
-
return poll_request(false)
|
140
|
+
return poll_request(nil, false)
|
141
141
|
end
|
142
142
|
|
143
143
|
def send_sync(name, request,
|
@@ -155,7 +155,7 @@ module CloudI
|
|
155
155
|
OtpErlangBinary.new(request_info),
|
156
156
|
OtpErlangBinary.new(request),
|
157
157
|
timeout, priority]))
|
158
|
-
return poll_request(false)
|
158
|
+
return poll_request(nil, false)
|
159
159
|
end
|
160
160
|
|
161
161
|
def mcast_async(name, request,
|
@@ -173,7 +173,7 @@ module CloudI
|
|
173
173
|
OtpErlangBinary.new(request_info),
|
174
174
|
OtpErlangBinary.new(request),
|
175
175
|
timeout, priority]))
|
176
|
-
return poll_request(false)
|
176
|
+
return poll_request(nil, false)
|
177
177
|
end
|
178
178
|
|
179
179
|
def forward_(command, name, request_info, request,
|
@@ -298,7 +298,7 @@ module CloudI
|
|
298
298
|
send(Erlang.term_to_binary([:recv_async, timeout,
|
299
299
|
OtpErlangBinary.new(trans_id),
|
300
300
|
consume]))
|
301
|
-
return poll_request(false)
|
301
|
+
return poll_request(nil, false)
|
302
302
|
end
|
303
303
|
|
304
304
|
def callback(command, name, pattern, request_info, request,
|
@@ -331,6 +331,12 @@ module CloudI
|
|
331
331
|
if not response.kind_of?(String)
|
332
332
|
response = ''
|
333
333
|
end
|
334
|
+
rescue InvalidInputException => e
|
335
|
+
raise e
|
336
|
+
rescue MessageDecodingException => e
|
337
|
+
raise e
|
338
|
+
rescue TerminateException => e
|
339
|
+
raise e
|
334
340
|
rescue ReturnAsyncException
|
335
341
|
return
|
336
342
|
rescue ForwardAsyncException
|
@@ -374,6 +380,12 @@ module CloudI
|
|
374
380
|
if not response.kind_of?(String)
|
375
381
|
response = ''
|
376
382
|
end
|
383
|
+
rescue InvalidInputException => e
|
384
|
+
raise e
|
385
|
+
rescue MessageDecodingException => e
|
386
|
+
raise e
|
387
|
+
rescue TerminateException => e
|
388
|
+
raise e
|
377
389
|
rescue ReturnSyncException
|
378
390
|
return
|
379
391
|
rescue ForwardSyncException
|
@@ -430,6 +442,8 @@ module CloudI
|
|
430
442
|
when MESSAGE_KEEPALIVE
|
431
443
|
send(Erlang.term_to_binary(:keepalive))
|
432
444
|
i += j
|
445
|
+
else
|
446
|
+
raise MessageDecodingException
|
433
447
|
end
|
434
448
|
if i > data_size
|
435
449
|
raise MessageDecodingException
|
@@ -441,29 +455,35 @@ module CloudI
|
|
441
455
|
end
|
442
456
|
end
|
443
457
|
|
444
|
-
def poll_request(external)
|
458
|
+
def poll_request(timeout, external)
|
445
459
|
if @terminate
|
446
|
-
return
|
460
|
+
return false
|
447
461
|
elsif external and not @initialization_complete
|
448
462
|
send(Erlang.term_to_binary(:polling))
|
449
463
|
@initialization_complete = true
|
450
464
|
end
|
451
465
|
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
end
|
466
|
+
poll_timer = nil
|
467
|
+
if timeout.nil? or timeout < 0
|
468
|
+
timeout_value = nil
|
469
|
+
elsif timeout == 0
|
470
|
+
timeout_value = 0
|
471
|
+
elsif timeout > 0
|
472
|
+
poll_timer = Time.now
|
473
|
+
timeout_value = timeout * 0.001
|
461
474
|
end
|
462
|
-
|
475
|
+
result = IO.select([@s], nil, [@s], timeout_value)
|
476
|
+
if result.nil?
|
477
|
+
return true
|
478
|
+
end
|
479
|
+
if result[2].length > 0
|
480
|
+
return false
|
481
|
+
end
|
482
|
+
|
463
483
|
data = recv('')
|
464
484
|
data_size = data.bytesize
|
465
485
|
if data_size == 0
|
466
|
-
return
|
486
|
+
return false
|
467
487
|
end
|
468
488
|
i = 0; j = 4
|
469
489
|
|
@@ -511,22 +531,22 @@ module CloudI
|
|
511
531
|
i += j; j = request_size + 1 + 4 + 1 + 16 + 4
|
512
532
|
tmp = data[i, j].unpack("a#{request_size}xLca16L")
|
513
533
|
request = tmp[0]
|
514
|
-
|
534
|
+
request_timeout = tmp[1]
|
515
535
|
priority = tmp[2]
|
516
536
|
trans_id = tmp[3]
|
517
537
|
pid_size = tmp[4]
|
518
538
|
i += j; j = pid_size
|
519
|
-
pid = data[i, j]
|
539
|
+
pid = data[i, j]
|
520
540
|
i += j
|
521
541
|
if i != data_size
|
522
542
|
API.assert{external == true}
|
523
543
|
if not handle_events(external, data, data_size, i)
|
524
|
-
return
|
544
|
+
return false
|
525
545
|
end
|
526
546
|
end
|
527
547
|
data.clear()
|
528
548
|
callback(command, name, pattern, request_info, request,
|
529
|
-
|
549
|
+
request_timeout, priority, trans_id,
|
530
550
|
Erlang.binary_to_term(pid))
|
531
551
|
when MESSAGE_RECV_ASYNC, MESSAGE_RETURN_SYNC
|
532
552
|
i += j; j = 4
|
@@ -547,7 +567,7 @@ module CloudI
|
|
547
567
|
return [response_info, response, trans_id]
|
548
568
|
when MESSAGE_RETURN_ASYNC
|
549
569
|
i += j; j = 16
|
550
|
-
trans_id = data[i, j]
|
570
|
+
trans_id = data[i, j]
|
551
571
|
i += j
|
552
572
|
if i != data_size
|
553
573
|
API.assert{external == false}
|
@@ -576,7 +596,7 @@ module CloudI
|
|
576
596
|
return count
|
577
597
|
when MESSAGE_TERM
|
578
598
|
if not handle_events(external, data, data_size, i, command)
|
579
|
-
return
|
599
|
+
return false
|
580
600
|
end
|
581
601
|
API.assert{false}
|
582
602
|
when MESSAGE_REINIT
|
@@ -604,33 +624,52 @@ module CloudI
|
|
604
624
|
raise MessageDecodingException
|
605
625
|
end
|
606
626
|
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
627
|
+
if not poll_timer.nil?
|
628
|
+
poll_timer_new = Time.now
|
629
|
+
elapsed = [0,
|
630
|
+
((poll_timer_new -
|
631
|
+
poll_timer) * 1000.0).floor].max
|
632
|
+
poll_timer = poll_timer_new
|
633
|
+
if elapsed >= timeout
|
634
|
+
timeout = 0
|
635
|
+
else
|
636
|
+
timeout -= elapsed
|
612
637
|
end
|
613
|
-
|
614
|
-
|
638
|
+
end
|
639
|
+
if not timeout_value.nil?
|
640
|
+
if timeout == 0
|
641
|
+
return true
|
642
|
+
elsif timeout > 0
|
643
|
+
timeout_value = timeout * 0.001
|
615
644
|
end
|
616
645
|
end
|
646
|
+
result = IO.select([@s], nil, [@s], timeout_value)
|
647
|
+
if result.nil?
|
648
|
+
return true
|
649
|
+
end
|
650
|
+
if result[2].length > 0
|
651
|
+
return false
|
652
|
+
end
|
617
653
|
|
618
654
|
data = recv(data)
|
619
655
|
data_size = data.bytesize
|
620
656
|
if data_size == 0
|
621
|
-
return
|
657
|
+
return false
|
622
658
|
end
|
623
659
|
i = 0; j = 4
|
624
660
|
end
|
625
661
|
end
|
626
662
|
|
627
|
-
def poll
|
628
|
-
|
663
|
+
def poll(timeout=nil)
|
664
|
+
if timeout.nil?
|
665
|
+
timeout = -1
|
666
|
+
end
|
667
|
+
return poll_request(timeout, true)
|
629
668
|
end
|
630
669
|
|
631
|
-
def
|
670
|
+
def text_key_value_parse(text)
|
632
671
|
result = {}
|
633
|
-
data =
|
672
|
+
data = text.split(NULL.chr)
|
634
673
|
(0...(data.length)).step(2).each do |i|
|
635
674
|
value = result[data[i]]
|
636
675
|
if value == nil
|
@@ -641,15 +680,15 @@ module CloudI
|
|
641
680
|
result[data[i]] = [value, data[i + 1]]
|
642
681
|
end
|
643
682
|
end
|
644
|
-
result
|
683
|
+
return result
|
645
684
|
end
|
646
685
|
|
647
686
|
def request_http_qs_parse(request)
|
648
|
-
|
687
|
+
return text_key_value_parse(request)
|
649
688
|
end
|
650
689
|
|
651
690
|
def info_key_value_parse(message_info)
|
652
|
-
|
691
|
+
return text_key_value_parse(message_info)
|
653
692
|
end
|
654
693
|
|
655
694
|
def self.assert
|
@@ -659,7 +698,7 @@ module CloudI
|
|
659
698
|
private :callback
|
660
699
|
private :handle_events
|
661
700
|
private :poll_request
|
662
|
-
private :
|
701
|
+
private :text_key_value_parse
|
663
702
|
private
|
664
703
|
|
665
704
|
def send(data)
|
@@ -693,7 +732,7 @@ module CloudI
|
|
693
732
|
end
|
694
733
|
end
|
695
734
|
end
|
696
|
-
data
|
735
|
+
return data
|
697
736
|
end
|
698
737
|
|
699
738
|
MESSAGE_INIT = 1
|
metadata
CHANGED
@@ -1,117 +1,132 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudi
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 4
|
9
|
+
- 0
|
10
|
+
version: 1.4.0
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Michael Truog
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
|
-
cert_chain:
|
12
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OIoICMefZOiJfTC9UkVkW+554IXNBu3vVxLc0nlCqmuf/aQGaFBUm9MLA
|
39
|
-
|
40
32
|
oD5CmlrU9OrEl2fPxqTHAwFgLNre8e2EWtm2OhBg73JTHRVVyBLpSK5GRUDzhJtZ
|
41
|
-
|
42
33
|
7a2ocAE2AgFKpISNxIUe4Zz9O2thg3iryLh9prjETJTUfxDjBmHdx+YkNAblRa2w
|
43
|
-
|
44
34
|
k9A+nCZzZECcR5ZZYSeaK6MCugGmXUhAkDbuWumCzu/RAghlVC9RFFQt7o1SwGQp
|
45
|
-
|
46
35
|
LdvYOeJbviyiH1q1rC3NAJNC4P7Q41zx1OYa8S9M5qn+JpE0ZsomnZyGunWaya9Q
|
47
|
-
|
48
36
|
bTD/aw==
|
49
|
-
|
50
37
|
-----END CERTIFICATE-----
|
51
38
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
- !ruby/object:Gem::Dependency
|
39
|
+
date: 2014-12-20 00:00:00 Z
|
40
|
+
dependencies:
|
41
|
+
- !ruby/object:Gem::Dependency
|
56
42
|
name: erlang_rb
|
57
|
-
|
43
|
+
prerelease: false
|
44
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
58
45
|
none: false
|
59
|
-
requirements:
|
46
|
+
requirements:
|
60
47
|
- - ~>
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
hash: 7
|
50
|
+
segments:
|
51
|
+
- 1
|
52
|
+
- 4
|
53
|
+
version: "1.4"
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 7
|
57
|
+
segments:
|
58
|
+
- 1
|
59
|
+
- 4
|
60
|
+
- 0
|
61
|
+
version: 1.4.0
|
66
62
|
type: :runtime
|
67
|
-
|
68
|
-
|
69
|
-
- !ruby/object:Gem::Dependency
|
63
|
+
version_requirements: *id001
|
64
|
+
- !ruby/object:Gem::Dependency
|
70
65
|
name: erlang_rb
|
71
|
-
|
66
|
+
prerelease: false
|
67
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
72
68
|
none: false
|
73
|
-
requirements:
|
69
|
+
requirements:
|
74
70
|
- - ~>
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 7
|
73
|
+
segments:
|
74
|
+
- 1
|
75
|
+
- 4
|
76
|
+
version: "1.4"
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
hash: 7
|
80
|
+
segments:
|
81
|
+
- 1
|
82
|
+
- 4
|
83
|
+
- 0
|
84
|
+
version: 1.4.0
|
80
85
|
type: :development
|
81
|
-
|
82
|
-
version_requirements: *15925360
|
86
|
+
version_requirements: *id002
|
83
87
|
description: Ruby CloudI API
|
84
88
|
email: mjtruog@gmail.com
|
85
89
|
executables: []
|
90
|
+
|
86
91
|
extensions: []
|
87
|
-
|
92
|
+
|
93
|
+
extra_rdoc_files:
|
88
94
|
- README.markdown
|
89
|
-
files:
|
95
|
+
files:
|
90
96
|
- lib/cloudi.rb
|
91
97
|
- README.markdown
|
92
98
|
homepage: http://cloudi.org
|
93
|
-
licenses:
|
99
|
+
licenses:
|
94
100
|
- BSD
|
95
101
|
post_install_message:
|
96
102
|
rdoc_options: []
|
97
|
-
|
103
|
+
|
104
|
+
require_paths:
|
98
105
|
- lib
|
99
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
107
|
none: false
|
101
|
-
requirements:
|
102
|
-
- -
|
103
|
-
- !ruby/object:Gem::Version
|
104
|
-
|
105
|
-
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
hash: 3
|
112
|
+
segments:
|
113
|
+
- 0
|
114
|
+
version: "0"
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
116
|
none: false
|
107
|
-
requirements:
|
108
|
-
- -
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
hash: 3
|
121
|
+
segments:
|
122
|
+
- 0
|
123
|
+
version: "0"
|
111
124
|
requirements: []
|
125
|
+
|
112
126
|
rubyforge_project:
|
113
|
-
rubygems_version: 1.8.
|
127
|
+
rubygems_version: 1.8.15
|
114
128
|
signing_key:
|
115
129
|
specification_version: 3
|
116
130
|
summary: CloudI API
|
117
131
|
test_files: []
|
132
|
+
|
metadata.gz.sig
CHANGED
Binary file
|