grpc_kit 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/grpc_kit/client.rb +9 -2
- data/lib/grpc_kit/grpc/dsl.rb +4 -2
- data/lib/grpc_kit/method_config.rb +5 -5
- data/lib/grpc_kit/rpc_desc.rb +19 -2
- data/lib/grpc_kit/rpcs.rb +3 -0
- data/lib/grpc_kit/server.rb +11 -3
- data/lib/grpc_kit/version.rb +1 -1
- metadata +3 -4
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9713e72ba462451e689cd4aaa676994c96d591eaae9ddb9c4552f3d741431f7
|
4
|
+
data.tar.gz: 77af2186c14504d79c801ac216b7cb7576ddd8f516c7451f3e571bab3ade41c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 177555f8840c371e7d83cc67f6227a4043fe80fa06c4074b7ae5fcb9273af3f4115f06a4be94e4ea8491f6a5f606832114605d23611f27face8819bac937e2ab
|
7
|
+
data.tar.gz: 8a05c9f24bd762a845ed1a8f9652d108f3a281042c04387545c32954fd8c5bfa8a96e806229c8647dc4be6b3f75f334e0b1123ae7c25da06012ce325e629b7c4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v0.5.0 (2021-04-22)
|
4
|
+
|
5
|
+
- improve: Configurable max_receive_message_size and max_send_message_size ([#33](https://github.com/cookpad/grpc_kit/pull/33))
|
6
|
+
|
3
7
|
## v0.4.0 (2020-10-23)
|
4
8
|
|
5
9
|
- bug: Fix Ruby 2.7 keyword argument separation warnings ([#27](https://github.com/cookpad/grpc_kit/pull/27))
|
data/lib/grpc_kit/client.rb
CHANGED
@@ -12,7 +12,9 @@ module GrpcKit
|
|
12
12
|
# @param authority [nil, String]
|
13
13
|
# @param interceptors [Array<GrpcKit::Grpc::ClientInterceptor>] list of interceptors
|
14
14
|
# @param timeout [nil, Integer, String]
|
15
|
-
|
15
|
+
# @param max_receive_message_size [Integer, nil] Specify the default maximum size of inbound message in bytes. Default to 4MB.
|
16
|
+
# @param max_send_message_size [Integer, nil] Specify the default maximum size of outbound message in bytes. Default to 4MB.
|
17
|
+
def initialize(sock, authority: nil, interceptors: [], timeout: nil, max_receive_message_size: nil, max_send_message_size: nil)
|
16
18
|
@sock = sock
|
17
19
|
@authority =
|
18
20
|
if authority
|
@@ -24,7 +26,12 @@ module GrpcKit
|
|
24
26
|
|
25
27
|
@timeout = timeout && GrpcKit::GrpcTime.new(timeout)
|
26
28
|
|
27
|
-
|
29
|
+
# Defined at GrpcKit::Grpc::Dsl#.rpc_stub_class
|
30
|
+
build_rpcs(
|
31
|
+
interceptors,
|
32
|
+
max_receive_message_size: max_receive_message_size,
|
33
|
+
max_send_message_size: max_send_message_size,
|
34
|
+
)
|
28
35
|
end
|
29
36
|
|
30
37
|
# @param rpc [GrpcKit::Rpcs::Client::RequestResponse]
|
data/lib/grpc_kit/grpc/dsl.rb
CHANGED
@@ -7,6 +7,8 @@ require 'grpc_kit/grpc/stream'
|
|
7
7
|
|
8
8
|
module GrpcKit
|
9
9
|
module Grpc
|
10
|
+
# Methods under GrpcKit::Grpc::Dsl is available for classes include GRPC::GenericService.
|
11
|
+
# See also: GrpcKit::Grpc::GenericService
|
10
12
|
module Dsl
|
11
13
|
# @param value [String]
|
12
14
|
attr_accessor :service_name
|
@@ -73,9 +75,9 @@ module GrpcKit
|
|
73
75
|
super
|
74
76
|
end
|
75
77
|
|
76
|
-
define_method(:build_rpcs) do |interceptors|
|
78
|
+
define_method(:build_rpcs) do |interceptors, **options|
|
77
79
|
rpc_descs_.each do |method_name, rpc_desc|
|
78
|
-
@rpcs[method_name] = rpc_desc.build_client(interceptors: interceptors)
|
80
|
+
@rpcs[method_name] = rpc_desc.build_client(interceptors: interceptors, **options)
|
79
81
|
end
|
80
82
|
end
|
81
83
|
private :build_rpcs
|
@@ -1,6 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module GrpcKit
|
4
|
+
MAX_SERVER_RECEIVE_MESSAGE_SIZE = 1024 * 1024 * 4
|
5
|
+
MAX_SERVER_SEND_MESSAGE_SIZE = 1024 * 1024 * 4
|
6
|
+
MAX_CLIENT_RECEIVE_MESSAGE_SIZE = 1024 * 1024 * 4
|
7
|
+
MAX_CLIENT_SEND_MESSAGE_SIZE = 1024 * 1024 * 4
|
8
|
+
|
4
9
|
MethodConfig = Struct.new(
|
5
10
|
:path,
|
6
11
|
:ruby_style_method_name,
|
@@ -12,11 +17,6 @@ module GrpcKit
|
|
12
17
|
:max_send_message_size,
|
13
18
|
:compressor_type,
|
14
19
|
) do
|
15
|
-
MAX_SERVER_RECEIVE_MESSAGE_SIZE = 1024 * 1024 * 4
|
16
|
-
MAX_SERVER_SEND_MESSAGE_SIZE = 1024 * 1024 * 4
|
17
|
-
MAX_CLIENT_RECEIVE_MESSAGE_SIZE = 1024 * 1024 * 4
|
18
|
-
MAX_CLIENT_SEND_MESSAGE_SIZE = 1024 * 1024 * 4
|
19
|
-
|
20
20
|
def self.build_for_server(
|
21
21
|
path:, ruby_style_method_name:, codec:, service_name:, method_name:, interceptor:,
|
22
22
|
max_receive_message_size: MAX_SERVER_RECEIVE_MESSAGE_SIZE, max_send_message_size: MAX_SERVER_SEND_MESSAGE_SIZE, compressor_type: ''
|
data/lib/grpc_kit/rpc_desc.rb
CHANGED
@@ -38,10 +38,21 @@ module GrpcKit
|
|
38
38
|
@service_name = service_name
|
39
39
|
end
|
40
40
|
|
41
|
+
# @return [String]
|
42
|
+
attr_reader :name, :service_name
|
43
|
+
|
44
|
+
# @return [Class, GrpcKit::Grpc::Stream]
|
45
|
+
attr_reader :marshal, :unmarshal
|
46
|
+
|
47
|
+
# @return [Symbol]
|
48
|
+
attr_reader :marshal_method, :unmarshal_method
|
49
|
+
|
41
50
|
# @param handler [GrpcKit::Grpc::GenericService]
|
42
51
|
# @param interceptors [Array<GrpcKit::Grpc::ServerInterceptor>]
|
52
|
+
# @param max_receive_message_size [Integer, nil]
|
53
|
+
# @param max_send_message_size [Integer, nil]
|
43
54
|
# @return [#invoke] Server version of rpc class
|
44
|
-
def build_server(handler, interceptors: [])
|
55
|
+
def build_server(handler, interceptors: [], max_send_message_size: nil, max_receive_message_size: nil)
|
45
56
|
inter = interceptors.empty? ? nil : server_interceptor.new(interceptors)
|
46
57
|
|
47
58
|
config = GrpcKit::MethodConfig.build_for_server(
|
@@ -51,13 +62,17 @@ module GrpcKit
|
|
51
62
|
service_name: @service_name,
|
52
63
|
method_name: @name,
|
53
64
|
interceptor: inter,
|
65
|
+
max_receive_message_size: max_receive_message_size || GrpcKit::MAX_SERVER_RECEIVE_MESSAGE_SIZE,
|
66
|
+
max_send_message_size: max_send_message_size || GrpcKit::MAX_SERVER_SEND_MESSAGE_SIZE,
|
54
67
|
)
|
55
68
|
server.new(handler, config)
|
56
69
|
end
|
57
70
|
|
58
71
|
# @param interceptors [Array<GrpcKit::Grpc::ClientInterceptor>]
|
72
|
+
# @param max_receive_message_size [Integer, nil]
|
73
|
+
# @param max_send_message_size [Integer, nil]
|
59
74
|
# @return [#invoke] Client version of rpc class
|
60
|
-
def build_client(interceptors: [])
|
75
|
+
def build_client(interceptors: [], max_send_message_size: nil, max_receive_message_size: nil)
|
61
76
|
inter = interceptors.empty? ? nil : client_interceptor.new(interceptors)
|
62
77
|
|
63
78
|
config = GrpcKit::MethodConfig.build_for_client(
|
@@ -67,6 +82,8 @@ module GrpcKit
|
|
67
82
|
service_name: @service_name,
|
68
83
|
method_name: @name,
|
69
84
|
interceptor: inter,
|
85
|
+
max_receive_message_size: max_receive_message_size || GrpcKit::MAX_CLIENT_RECEIVE_MESSAGE_SIZE,
|
86
|
+
max_send_message_size: max_send_message_size || GrpcKit::MAX_CLIENT_SEND_MESSAGE_SIZE,
|
70
87
|
)
|
71
88
|
client.new(config)
|
72
89
|
end
|
data/lib/grpc_kit/rpcs.rb
CHANGED
data/lib/grpc_kit/server.rb
CHANGED
@@ -10,11 +10,15 @@ module GrpcKit
|
|
10
10
|
# @param shutdown_timeout [Integer] Number of seconds to wait for the server shutdown
|
11
11
|
# @param min_pool_size [Integer] A mininum thread pool size
|
12
12
|
# @param max_pool_size [Integer] A maximum thread pool size
|
13
|
-
|
13
|
+
# @param max_receive_message_size [Integer, nil] Specify the maximum size of inbound message in bytes. Default to 4MB.
|
14
|
+
# @param max_send_message_size [Integer, nil] Specify the maximum size of outbound message in bytes. Default to 4MB.
|
15
|
+
def initialize(interceptors: [], shutdown_timeout: 30, min_pool_size: nil, max_pool_size: nil, settings: [], max_receive_message_size: nil, max_send_message_size: nil)
|
14
16
|
@interceptors = interceptors
|
15
17
|
@shutdown_timeout = shutdown_timeout
|
16
18
|
@min_pool_size = min_pool_size || GrpcKit::RpcDispatcher::DEFAULT_MIN
|
17
19
|
@max_pool_size = max_pool_size || GrpcKit::RpcDispatcher::DEFAULT_MAX
|
20
|
+
@max_receive_message_size = max_receive_message_size
|
21
|
+
@max_send_message_size = max_send_message_size
|
18
22
|
@sessions = []
|
19
23
|
@rpc_descs = {}
|
20
24
|
@mutex = Mutex.new
|
@@ -37,8 +41,12 @@ module GrpcKit
|
|
37
41
|
raise "Duplicated method registered #{path}, class: #{klass}"
|
38
42
|
end
|
39
43
|
|
40
|
-
|
41
|
-
|
44
|
+
@rpc_descs[path] = rpc_desc.build_server(
|
45
|
+
handler.is_a?(Class) ? handler.new : handler,
|
46
|
+
interceptors: @interceptors,
|
47
|
+
max_receive_message_size: @max_receive_message_size,
|
48
|
+
max_send_message_size: @max_send_message_size,
|
49
|
+
)
|
42
50
|
end
|
43
51
|
end
|
44
52
|
|
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.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuta Iwama
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ds9
|
@@ -147,7 +147,6 @@ files:
|
|
147
147
|
- ".gitignore"
|
148
148
|
- ".rspec"
|
149
149
|
- ".rubocop.yml"
|
150
|
-
- ".ruby-version"
|
151
150
|
- CHANGELOG.md
|
152
151
|
- Gemfile
|
153
152
|
- LICENSE.txt
|
@@ -253,7 +252,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
253
252
|
- !ruby/object:Gem::Version
|
254
253
|
version: '0'
|
255
254
|
requirements: []
|
256
|
-
rubygems_version: 3.1.
|
255
|
+
rubygems_version: 3.1.4
|
257
256
|
signing_key:
|
258
257
|
specification_version: 4
|
259
258
|
summary: A kit for creating gRPC server/client
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.5
|