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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93b1358631d8f55fb408daa3644ff3966d518fdcc0bac693468e679d8ea6a144
4
- data.tar.gz: 18c6b183a8904c7ad65ea588ec557be7f063107e3d8c191bf54f1c52fdf16915
3
+ metadata.gz: d74cc1cb91c2d6ae3a85ad925d8e94b317bcc9f13ecb51d7b32b8edfd1ef8d41
4
+ data.tar.gz: f14c874d78b97fd52d87685d16dafe9d63685817c7bf759608319e42b60ab64d
5
5
  SHA512:
6
- metadata.gz: 328200b7e1cfbd503abb5c6503d9efc8851f76c7f964bbeb9ee61986d2a7aa0f89ed318df434bcc14cff28702d1919267bf11516900a26022a2dc9744a95ac88
7
- data.tar.gz: 22b0d11ce99abedc64c8e46216025ecd753966f7114ef5351484c0b3c0a2273517a82cc524b1923dcf3dd082b3b81572c388759813d476cde13c1fd24371d95e
6
+ metadata.gz: 04f3fc642a27bb61f4f279783b1ad4bfe97120804d039c8e2d7c866aee1c3aee56ac430fe1826ea493b781af7b5cef9dd54c4aeadaa6c818ff768e79e95e95ac
7
+ data.tar.gz: 33b4035c9a686261c34fd0f7ed245c6f1744b69b76998c7be60afdd13c6887785a526ffe3c5f7de7472d434c6d18dff6752a154ae70db4427da38908f6f7067d
checksums.yaml.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -98,6 +98,8 @@ The following example invokes the call in the opposite direction, from the subpr
98
98
  # call returns when the IO is closed by the subprocess
99
99
  ```
100
100
 
101
+ Full API documentation is here: https://rubydoc.info/gems/ccrpc
102
+
101
103
 
102
104
  ## Development
103
105
 
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.
@@ -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. See {#call} for more description.
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
- pr = proc do
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.reject{|k,v| v.nil? }.each do |key, value|
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.reject{|k,v| v.nil? }.each do |key, value|
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
@@ -1,3 +1,3 @@
1
1
  module Ccrpc
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
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.3.1
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
  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
+ /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-07-11 00:00:00.000000000 Z
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