ccrpc 0.3.1 → 0.4.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
- checksums.yaml.gz.sig +0 -0
- data/README.md +2 -0
- data/ccrpc.gemspec +1 -0
- data/lib/ccrpc/rpc_connection.rb +12 -9
- data/lib/ccrpc/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +23 -20
- 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: d74cc1cb91c2d6ae3a85ad925d8e94b317bcc9f13ecb51d7b32b8edfd1ef8d41
|
|
4
|
+
data.tar.gz: f14c874d78b97fd52d87685d16dafe9d63685817c7bf759608319e42b60ab64d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 04f3fc642a27bb61f4f279783b1ad4bfe97120804d039c8e2d7c866aee1c3aee56ac430fe1826ea493b781af7b5cef9dd54c4aeadaa6c818ff768e79e95e95ac
|
|
7
|
+
data.tar.gz: 33b4035c9a686261c34fd0f7ed245c6f1744b69b76998c7be60afdd13c6887785a526ffe3c5f7de7472d434c6d18dff6752a154ae70db4427da38908f6f7067d
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/README.md
CHANGED
data/ccrpc.gemspec
CHANGED
|
@@ -13,6 +13,7 @@ Gem::Specification.new do |spec|
|
|
|
13
13
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
|
14
14
|
|
|
15
15
|
spec.metadata["homepage_uri"] = spec.homepage
|
|
16
|
+
spec.metadata["documentation_uri"] = "https://rubydoc.info/gems/ccrpc"
|
|
16
17
|
|
|
17
18
|
# Specify which files should be added to the gem when it is released.
|
|
18
19
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
data/lib/ccrpc/rpc_connection.rb
CHANGED
|
@@ -84,7 +84,10 @@ class RpcConnection
|
|
|
84
84
|
#
|
|
85
85
|
# @param [IO] read_io readable IO object for reception of data
|
|
86
86
|
# @param [IO] write_io writable IO object for transmission of data
|
|
87
|
-
# @param [Boolean] lazy_answers Enable or disable lazy results.
|
|
87
|
+
# @param [Boolean] lazy_answers Enable or disable lazy results.
|
|
88
|
+
# If enabled the return value of #call is always a Ccrpc::Promise object.
|
|
89
|
+
# It behaves like an ordinary +nil+ or Hash object, but the actual IO blocking operation is delayed to the first method call on the Promise object.
|
|
90
|
+
# See {#call} for more description.
|
|
88
91
|
def initialize(read_io, write_io, lazy_answers: false)
|
|
89
92
|
super()
|
|
90
93
|
|
|
@@ -160,10 +163,11 @@ class RpcConnection
|
|
|
160
163
|
# @return [Hash] Received answer parameters.
|
|
161
164
|
# @return [Promise] Received answer parameters enveloped by a Promise.
|
|
162
165
|
# This type of answers can be enabled by +RpcConnection#new(lazy_answers: true)+
|
|
163
|
-
# The Promise object is returned as soon as the RPC call is sent, but before waiting for the corresponding answer.
|
|
166
|
+
# The Promise object is returned as soon as the RPC call is sent and a callback receiver is registered, but before waiting for the corresponding answer.
|
|
164
167
|
# This way several calls can be send in parallel without using threads.
|
|
165
168
|
# As soon as a method is called on the Promise object, this method is blocked until the RPC answer was received.
|
|
166
|
-
# The Promise object then behaves like a Hash object.
|
|
169
|
+
# The Promise object then behaves like a Hash or +nil+ object.
|
|
170
|
+
# It is recommended to use Promise#itself to trigger waiting for call answers or callbacks (although any other method triggers waiting as well).
|
|
167
171
|
# @return [NilClass] Waiting for further answers was stopped gracefully by either returning +[hash, true]+ from the block or because the connection was closed.
|
|
168
172
|
def call(func=nil, params={}, &block)
|
|
169
173
|
call_intern(func, params, &block)
|
|
@@ -180,7 +184,7 @@ class RpcConnection
|
|
|
180
184
|
|
|
181
185
|
send_call(func, params, id, recv_id) if func
|
|
182
186
|
|
|
183
|
-
|
|
187
|
+
maybe_lazy do
|
|
184
188
|
@answers_mutex.synchronize do
|
|
185
189
|
res = loop do
|
|
186
190
|
# Is a callback pending for this thread?
|
|
@@ -223,7 +227,6 @@ class RpcConnection
|
|
|
223
227
|
res
|
|
224
228
|
end
|
|
225
229
|
end
|
|
226
|
-
func ? maybe_lazy(&pr) : pr.call
|
|
227
230
|
end
|
|
228
231
|
|
|
229
232
|
def next_id
|
|
@@ -235,7 +238,7 @@ class RpcConnection
|
|
|
235
238
|
def send_call(func, params, id, recv_id=nil)
|
|
236
239
|
to_send = String.new
|
|
237
240
|
@write_mutex.synchronize do
|
|
238
|
-
params.
|
|
241
|
+
params.compact.each do |key, value|
|
|
239
242
|
to_send << Escape.escape(key.to_s) << "\t" <<
|
|
240
243
|
Escape.escape(value.to_s) << "\n"
|
|
241
244
|
if to_send.bytesize > 9999
|
|
@@ -246,15 +249,15 @@ class RpcConnection
|
|
|
246
249
|
to_send << Escape.escape(func.to_s) << "\a#{id}"
|
|
247
250
|
to_send << "\a#{recv_id}" if recv_id
|
|
248
251
|
@write_io.write(to_send << "\n")
|
|
252
|
+
@write_io.flush
|
|
249
253
|
end
|
|
250
|
-
@write_io.flush
|
|
251
254
|
after_write
|
|
252
255
|
end
|
|
253
256
|
|
|
254
257
|
def send_answer(answer, id)
|
|
255
258
|
to_send = String.new
|
|
256
259
|
@write_mutex.synchronize do
|
|
257
|
-
answer.
|
|
260
|
+
answer.compact.each do |key, value|
|
|
258
261
|
to_send << Escape.escape(key.to_s) << "\t" <<
|
|
259
262
|
Escape.escape(value.to_s) << "\n"
|
|
260
263
|
if to_send.bytesize > 9999
|
|
@@ -264,8 +267,8 @@ class RpcConnection
|
|
|
264
267
|
end
|
|
265
268
|
to_send << "\a#{id}" if id
|
|
266
269
|
@write_io.write(to_send << "\n")
|
|
270
|
+
@write_io.flush
|
|
267
271
|
end
|
|
268
|
-
@write_io.flush
|
|
269
272
|
after_write
|
|
270
273
|
end
|
|
271
274
|
|
data/lib/ccrpc/version.rb
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ccrpc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lars Kanis
|
|
@@ -10,26 +10,28 @@ bindir: exe
|
|
|
10
10
|
cert_chain:
|
|
11
11
|
- |
|
|
12
12
|
-----BEGIN CERTIFICATE-----
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
13
|
+
MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQsFADBIMRMwEQYDVQQDDApsYXJz
|
|
14
|
+
LmthbmlzMRwwGgYKCZImiZPyLGQBGRYMc2luY25vdmF0aW9uMRMwEQYKCZImiZPy
|
|
15
|
+
LGQBGRYDY29tMB4XDTIzMTAyNzIwNTc0MloXDTI0MTAyNjIwNTc0MlowSDETMBEG
|
|
16
|
+
A1UEAwwKbGFycy5rYW5pczEcMBoGCgmSJomT8ixkARkWDHNpbmNub3ZhdGlvbjET
|
|
17
|
+
MBEGCgmSJomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
|
|
18
|
+
ggEBAMJ4t2fVdVUixHSsWWXudvO7uCNKchxmrocupP5CNIvhkr0dYoJX+Hkghhh3
|
|
19
|
+
CFvo2gm8Oolfbl8Zvt/tBvJ/DhIaLWelhLpx7+gwoXkmrMvzOrJx1Wn4WdBSbKbX
|
|
20
|
+
0b7kbY9XKtZPp0e+5xCGDZRwGgdvEJrQqu//lgKdnuS5jMMqx4agqE0vZXmJ6CpV
|
|
21
|
+
FmUZ111nUmqUXO1lAJPrbYgx7PuUh+/KuaLTXe1TFuQKIK5HJoLQPRHSrleqRzD2
|
|
22
|
+
U7CagEy8gu8Ct9jD35QrxnBju0UyQlPlOB1v8wgfv50t8106Anke0NytTAH2uGKU
|
|
23
|
+
5fimmqnLQnFg8AzZnuaevliscYcCAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
|
|
24
|
+
DwQEAwIEsDAdBgNVHQ4EFgQU8WIevudyI+2h11gae0Sr2GzINeswJgYDVR0RBB8w
|
|
25
|
+
HYEbbGFycy5rYW5pc0BzaW5jbm92YXRpb24uY29tMCYGA1UdEgQfMB2BG2xhcnMu
|
|
26
|
+
a2FuaXNAc2luY25vdmF0aW9uLmNvbTANBgkqhkiG9w0BAQsFAAOCAQEAaD5tg+U+
|
|
27
|
+
/oolmp1/q6kCGqSaN4BIa40zDVFBaPsU02TXP7tpc+MD+WXwATMJAQ7MoIdFV2Rn
|
|
28
|
+
lCnMpKga9c+YvY3sKNeto9w+KvgIWSizHmUxqQmBpq74Xxz+fbBqZS/RboS0nY2p
|
|
29
|
+
ggnJJUsPbRXFFG09KPSNEGgsl5gipbX3k4HUlH/EaGrXCKswEr5WP5GwVm8t4J2r
|
|
30
|
+
t9W3c/nKB0fn3ouhpxl+AQU0dKqEanlH9rs7UNtVIgQtrH+xLMScdwgRzIVrwKVC
|
|
31
|
+
UAcSEq6uV4ESW20hEz8XvDK007nIk7R18hD6l5B9nqRN96+VO/5mex0iHV7lf79h
|
|
32
|
+
17EsHXVAFAb3dA==
|
|
31
33
|
-----END CERTIFICATE-----
|
|
32
|
-
date: 2024-
|
|
34
|
+
date: 2024-10-18 00:00:00.000000000 Z
|
|
33
35
|
dependencies: []
|
|
34
36
|
description: Simple bidirectional and thread safe RPC protocol. Works on arbitrary
|
|
35
37
|
Ruby IO objects.
|
|
@@ -60,6 +62,7 @@ licenses:
|
|
|
60
62
|
- MIT
|
|
61
63
|
metadata:
|
|
62
64
|
homepage_uri: https://github.com/larskanis/ccrpc
|
|
65
|
+
documentation_uri: https://rubydoc.info/gems/ccrpc
|
|
63
66
|
post_install_message:
|
|
64
67
|
rdoc_options: []
|
|
65
68
|
require_paths:
|
metadata.gz.sig
CHANGED
|
Binary file
|