grpc_kit 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/interceptors/client_logging_interceptor.rb +9 -4
- data/examples/interceptors/server_logging_interceptor.rb +5 -4
- data/lib/grpc.rb +2 -0
- data/lib/grpc_kit/calls/client_bidi_streamer.rb +2 -0
- data/lib/grpc_kit/calls.rb +3 -1
- data/lib/grpc_kit/grpc/core.rb +11 -0
- data/lib/grpc_kit/grpc/errors.rb +10 -0
- data/lib/grpc_kit/interceptors/client_bidi_streamer.rb +2 -2
- data/lib/grpc_kit/interceptors/client_client_streamer.rb +2 -2
- data/lib/grpc_kit/interceptors/client_server_streamer.rb +2 -2
- data/lib/grpc_kit/interceptors/server_bidi_streamer.rb +2 -2
- data/lib/grpc_kit/interceptors/server_client_streamer.rb +2 -2
- data/lib/grpc_kit/interceptors/server_server_streamer.rb +2 -2
- data/lib/grpc_kit/rpc_desc.rb +2 -2
- data/lib/grpc_kit/session/client_session.rb +2 -3
- data/lib/grpc_kit/session/server_session.rb +1 -1
- data/lib/grpc_kit/session/stream.rb +3 -5
- data/lib/grpc_kit/stream/client_stream.rb +1 -1
- data/lib/grpc_kit/stream/server_stream.rb +1 -1
- data/lib/grpc_kit/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8758d861d7f15069510676fb10809b04e88dcce7ad1fba77bbad60aa1140d508
|
4
|
+
data.tar.gz: 85c19955c66574e418d190915b9426aca629776a7ea7393ebabe44656c101ab4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9642ed431c3fbaa305c9b47f2ddc4ce189c0c2366dbfe80b5b7c913d0da80b5f8ec8240fc981c61646f9b140e72a9e4a7694378809bb2afcb85e69218cd0f612
|
7
|
+
data.tar.gz: 6b231bb959a8b2758a9ff48f06749dd4d6ab37369ce9a82f5a5070ed67ea9eba358d1ed4b9f0e27499eb56059119e87eef03f050adf59d6e042d2cc0c506586b
|
@@ -21,8 +21,9 @@ class LoggingInterceptor < GRPC::ClientInterceptor
|
|
21
21
|
yield(LoggingStream.new(call))
|
22
22
|
end
|
23
23
|
|
24
|
-
def bidi_streamer(**)
|
25
|
-
|
24
|
+
def bidi_streamer(call: nil, method: nil, **)
|
25
|
+
GrpcKit.logger.info("Started request method=#{method.name}, service_name=#{method.receiver.class.service_name}")
|
26
|
+
yield(LoggingStream.new(call))
|
26
27
|
end
|
27
28
|
|
28
29
|
class LoggingStream
|
@@ -31,18 +32,22 @@ class LoggingInterceptor < GRPC::ClientInterceptor
|
|
31
32
|
end
|
32
33
|
|
33
34
|
def send_msg(msg, **opts)
|
34
|
-
GrpcKit.logger.info("logging interceptor send #{msg}")
|
35
|
+
GrpcKit.logger.info("logging interceptor send #{msg.inspect}")
|
35
36
|
@stream.send_msg(msg, opts)
|
36
37
|
end
|
37
38
|
|
38
39
|
def recv(**opt)
|
39
40
|
@stream.recv(opt).tap do |v|
|
40
|
-
GrpcKit.logger.info("logging interceptor recv #{v}")
|
41
|
+
GrpcKit.logger.info("logging interceptor recv #{v.inspect}")
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
44
45
|
def close_and_recv
|
45
46
|
@stream.close_and_recv
|
46
47
|
end
|
48
|
+
|
49
|
+
def close_and_send
|
50
|
+
@stream.close_and_send
|
51
|
+
end
|
47
52
|
end
|
48
53
|
end
|
@@ -21,8 +21,9 @@ class LoggingInterceptor < GRPC::ServerInterceptor
|
|
21
21
|
yield(LoggingStream.new(call))
|
22
22
|
end
|
23
23
|
|
24
|
-
def bidi_streamer(**)
|
25
|
-
|
24
|
+
def bidi_streamer(call: nil, method: nil, **)
|
25
|
+
GrpcKit.logger.info("Started request method=#{method.name}, service_name=#{method.receiver.class.service_name}")
|
26
|
+
yield(LoggingStream.new(call))
|
26
27
|
end
|
27
28
|
|
28
29
|
class LoggingStream
|
@@ -31,13 +32,13 @@ class LoggingInterceptor < GRPC::ServerInterceptor
|
|
31
32
|
end
|
32
33
|
|
33
34
|
def send_msg(msg, **opt)
|
34
|
-
GrpcKit.logger.info("logging interceptor send #{msg}")
|
35
|
+
GrpcKit.logger.info("logging interceptor send #{msg.inspect}")
|
35
36
|
@stream.send_msg(msg, opt)
|
36
37
|
end
|
37
38
|
|
38
39
|
def recv(**opt)
|
39
40
|
@stream.recv(**opt).tap do |v|
|
40
|
-
GrpcKit.logger.info("logging interceptor recv #{v}")
|
41
|
+
GrpcKit.logger.info("logging interceptor recv #{v.inspect}")
|
41
42
|
end
|
42
43
|
end
|
43
44
|
end
|
data/lib/grpc.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
# Compatible file for xx_services_pb.rb and xx_pb.rb which are created by grpc-tools gem
|
4
4
|
require 'grpc_kit'
|
5
|
+
require 'grpc_kit/grpc/core'
|
6
|
+
require 'grpc_kit/grpc/errors'
|
5
7
|
require 'grpc_kit/grpc/generic_service'
|
6
8
|
require 'grpc_kit/grpc/interceptor'
|
7
9
|
require 'grpc_kit/grpc/logger'
|
data/lib/grpc_kit/calls.rb
CHANGED
@@ -49,7 +49,9 @@ module GrpcKit
|
|
49
49
|
|
50
50
|
# @return [Time] deadline of this rpc call
|
51
51
|
def deadline
|
52
|
-
@deadline
|
52
|
+
return @deadline if instance_variable_defined?(:@deadline)
|
53
|
+
|
54
|
+
@deadline = @timeout && @timeout.to_absolute_time
|
53
55
|
end
|
54
56
|
end
|
55
57
|
end
|
@@ -11,8 +11,8 @@ module GrpcKit
|
|
11
11
|
# @param call [GrpcKit::Calls::Client::BidiStreamer]
|
12
12
|
# @param metadata [Hash<String,String>]
|
13
13
|
def invoke(interceptor, call, metadata)
|
14
|
-
interceptor.bidi_streamer(requests: nil, call: call, method: call.method, metadata: metadata) do
|
15
|
-
yield(call, metadata)
|
14
|
+
interceptor.bidi_streamer(requests: nil, call: call, method: call.method, metadata: metadata) do |new_call = nil|
|
15
|
+
yield(new_call || call, metadata)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -13,8 +13,8 @@ module GrpcKit
|
|
13
13
|
def invoke(interceptor, call, metadata)
|
14
14
|
# We don't need a `:requests` parameter but,
|
15
15
|
# it shuoldn't remove from paramters due to having a compatibility of grpc gem.
|
16
|
-
interceptor.client_streamer(requests: nil, call: call, method: call.method, metadata: metadata) do
|
17
|
-
yield(call, metadata)
|
16
|
+
interceptor.client_streamer(requests: nil, call: call, method: call.method, metadata: metadata) do |new_call = nil|
|
17
|
+
yield(new_call || call, metadata)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -13,8 +13,8 @@ module GrpcKit
|
|
13
13
|
def invoke(interceptor, call, metadata)
|
14
14
|
# We don't need a `:request` parameter but,
|
15
15
|
# it shuoldn't remove from paramters due to having a compatibility of grpc gem.
|
16
|
-
interceptor.server_streamer(request: nil, call: call, method: call.method, metadata: metadata) do
|
17
|
-
yield(call, metadata)
|
16
|
+
interceptor.server_streamer(request: nil, call: call, method: call.method, metadata: metadata) do |new_call = nil|
|
17
|
+
yield(new_call || call, metadata)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -8,8 +8,8 @@ module GrpcKit
|
|
8
8
|
# @param interceptor [GrpcKit::GRPC::ServerInterceptor]
|
9
9
|
# @param call [GrpcKit::Calls::Client::BidiStreamer]
|
10
10
|
def invoke(interceptor, call)
|
11
|
-
interceptor.bidi_streamer(call: call, method: call.method) do
|
12
|
-
yield(call)
|
11
|
+
interceptor.bidi_streamer(call: call, method: call.method) do |new_call = nil|
|
12
|
+
yield(new_call || call)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -8,8 +8,8 @@ module GrpcKit
|
|
8
8
|
# @param interceptor [GrpcKit::GRPC::ServerInterceptor]
|
9
9
|
# @param call [GrpcKit::Calls::Client::ClientStreamer]
|
10
10
|
def invoke(interceptor, call)
|
11
|
-
interceptor.client_streamer(call: call, method: call.method) do
|
12
|
-
yield(call)
|
11
|
+
interceptor.client_streamer(call: call, method: call.method) do |new_call = nil|
|
12
|
+
yield(new_call || call)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -10,8 +10,8 @@ module GrpcKit
|
|
10
10
|
def invoke(interceptor, call)
|
11
11
|
# We don't need a `:request` parameter but,
|
12
12
|
# it shuoldn't remove from paramters due to having a compatibility of grpc gem.
|
13
|
-
interceptor.server_streamer(request: nil, call: call, method: call.method) do
|
14
|
-
yield(call)
|
13
|
+
interceptor.server_streamer(request: nil, call: call, method: call.method) do |new_call = nil|
|
14
|
+
yield(new_call || call)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
data/lib/grpc_kit/rpc_desc.rb
CHANGED
@@ -48,7 +48,7 @@ module GrpcKit
|
|
48
48
|
path: path,
|
49
49
|
ruby_style_method_name: ruby_style_name,
|
50
50
|
protobuf: server_protobuf,
|
51
|
-
service_name: @
|
51
|
+
service_name: @service_name,
|
52
52
|
method_name: @name,
|
53
53
|
interceptor: inter,
|
54
54
|
)
|
@@ -64,7 +64,7 @@ module GrpcKit
|
|
64
64
|
path: path,
|
65
65
|
ruby_style_method_name: ruby_style_name,
|
66
66
|
protobuf: client_protobuf,
|
67
|
-
service_name: @
|
67
|
+
service_name: @service_name,
|
68
68
|
method_name: @name,
|
69
69
|
interceptor: inter,
|
70
70
|
)
|
@@ -35,9 +35,8 @@ module GrpcKit
|
|
35
35
|
raise ConnectionClosing, "You can't send new request. becuase this connection will shuting down"
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
stream_id = submit_request(headers,
|
40
|
-
stream = GrpcKit::Session::Stream.new(stream_id: stream_id, send_data: data)
|
38
|
+
stream = GrpcKit::Session::Stream.new(stream_id: 0) # set later
|
39
|
+
stream_id = submit_request(headers, stream.pending_send_data).to_i
|
41
40
|
stream.stream_id = stream_id
|
42
41
|
@streams[stream_id] = stream
|
43
42
|
stream
|
@@ -202,7 +202,7 @@ module GrpcKit
|
|
202
202
|
raise "#{stream_id} is already existed"
|
203
203
|
end
|
204
204
|
|
205
|
-
@streams[stream_id] = GrpcKit::Session::Stream.new(stream_id: stream_id
|
205
|
+
@streams[stream_id] = GrpcKit::Session::Stream.new(stream_id: stream_id)
|
206
206
|
end
|
207
207
|
|
208
208
|
# nghttp2_session_callbacks_set_on_header_callback
|
@@ -19,14 +19,12 @@ module GrpcKit
|
|
19
19
|
attr_accessor :inflight, :stream_id
|
20
20
|
|
21
21
|
# @param stream_id [Integer]
|
22
|
-
|
23
|
-
# @param recv_data [GrpcKit::Session::RecvBuffer]
|
24
|
-
def initialize(stream_id:, send_data: nil, recv_data: nil)
|
22
|
+
def initialize(stream_id:)
|
25
23
|
@stream_id = stream_id
|
26
24
|
@end_read_stream = false
|
27
25
|
@headers = GrpcKit::Session::Headers.new
|
28
|
-
@pending_send_data =
|
29
|
-
@pending_recv_data =
|
26
|
+
@pending_send_data = GrpcKit::Session::SendBuffer.new
|
27
|
+
@pending_recv_data = GrpcKit::Session::RecvBuffer.new
|
30
28
|
|
31
29
|
@inflight = false
|
32
30
|
@trailer_data = {}
|
data/lib/grpc_kit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grpc_kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ganmacs
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ds9
|
@@ -182,7 +182,9 @@ files:
|
|
182
182
|
- lib/grpc_kit/calls/server_server_streamer.rb
|
183
183
|
- lib/grpc_kit/client.rb
|
184
184
|
- lib/grpc_kit/errors.rb
|
185
|
+
- lib/grpc_kit/grpc/core.rb
|
185
186
|
- lib/grpc_kit/grpc/dsl.rb
|
187
|
+
- lib/grpc_kit/grpc/errors.rb
|
186
188
|
- lib/grpc_kit/grpc/generic_service.rb
|
187
189
|
- lib/grpc_kit/grpc/interceptor.rb
|
188
190
|
- lib/grpc_kit/grpc/logger.rb
|