grpc 1.30.2-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/etc/roots.pem +4644 -0
- data/grpc_c.32.ruby +0 -0
- data/grpc_c.64.ruby +0 -0
- data/src/ruby/bin/math_client.rb +140 -0
- data/src/ruby/bin/math_pb.rb +34 -0
- data/src/ruby/bin/math_server.rb +191 -0
- data/src/ruby/bin/math_services_pb.rb +51 -0
- data/src/ruby/bin/noproto_client.rb +93 -0
- data/src/ruby/bin/noproto_server.rb +97 -0
- data/src/ruby/ext/grpc/ext-export.clang +1 -0
- data/src/ruby/ext/grpc/ext-export.gcc +6 -0
- data/src/ruby/ext/grpc/extconf.rb +107 -0
- data/src/ruby/ext/grpc/rb_byte_buffer.c +64 -0
- data/src/ruby/ext/grpc/rb_byte_buffer.h +35 -0
- data/src/ruby/ext/grpc/rb_call.c +1050 -0
- data/src/ruby/ext/grpc/rb_call.h +53 -0
- data/src/ruby/ext/grpc/rb_call_credentials.c +297 -0
- data/src/ruby/ext/grpc/rb_call_credentials.h +31 -0
- data/src/ruby/ext/grpc/rb_channel.c +835 -0
- data/src/ruby/ext/grpc/rb_channel.h +34 -0
- data/src/ruby/ext/grpc/rb_channel_args.c +155 -0
- data/src/ruby/ext/grpc/rb_channel_args.h +38 -0
- data/src/ruby/ext/grpc/rb_channel_credentials.c +267 -0
- data/src/ruby/ext/grpc/rb_channel_credentials.h +32 -0
- data/src/ruby/ext/grpc/rb_completion_queue.c +100 -0
- data/src/ruby/ext/grpc/rb_completion_queue.h +36 -0
- data/src/ruby/ext/grpc/rb_compression_options.c +470 -0
- data/src/ruby/ext/grpc/rb_compression_options.h +29 -0
- data/src/ruby/ext/grpc/rb_enable_cpp.cc +22 -0
- data/src/ruby/ext/grpc/rb_event_thread.c +143 -0
- data/src/ruby/ext/grpc/rb_event_thread.h +21 -0
- data/src/ruby/ext/grpc/rb_grpc.c +328 -0
- data/src/ruby/ext/grpc/rb_grpc.h +76 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +573 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +865 -0
- data/src/ruby/ext/grpc/rb_loader.c +57 -0
- data/src/ruby/ext/grpc/rb_loader.h +25 -0
- data/src/ruby/ext/grpc/rb_server.c +372 -0
- data/src/ruby/ext/grpc/rb_server.h +32 -0
- data/src/ruby/ext/grpc/rb_server_credentials.c +243 -0
- data/src/ruby/ext/grpc/rb_server_credentials.h +32 -0
- data/src/ruby/lib/grpc.rb +37 -0
- data/src/ruby/lib/grpc/2.3/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/2.4/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/2.5/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/2.6/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/2.7/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/core/status_codes.rb +135 -0
- data/src/ruby/lib/grpc/core/time_consts.rb +56 -0
- data/src/ruby/lib/grpc/errors.rb +277 -0
- data/src/ruby/lib/grpc/generic/active_call.rb +669 -0
- data/src/ruby/lib/grpc/generic/bidi_call.rb +233 -0
- data/src/ruby/lib/grpc/generic/client_stub.rb +501 -0
- data/src/ruby/lib/grpc/generic/interceptor_registry.rb +53 -0
- data/src/ruby/lib/grpc/generic/interceptors.rb +186 -0
- data/src/ruby/lib/grpc/generic/rpc_desc.rb +204 -0
- data/src/ruby/lib/grpc/generic/rpc_server.rb +551 -0
- data/src/ruby/lib/grpc/generic/service.rb +211 -0
- data/src/ruby/lib/grpc/google_rpc_status_utils.rb +40 -0
- data/src/ruby/lib/grpc/grpc.rb +24 -0
- data/src/ruby/lib/grpc/logconfig.rb +44 -0
- data/src/ruby/lib/grpc/notifier.rb +45 -0
- data/src/ruby/lib/grpc/structs.rb +15 -0
- data/src/ruby/lib/grpc/version.rb +18 -0
- data/src/ruby/pb/README.md +42 -0
- data/src/ruby/pb/generate_proto_ruby.sh +51 -0
- data/src/ruby/pb/grpc/health/checker.rb +75 -0
- data/src/ruby/pb/grpc/health/v1/health_pb.rb +31 -0
- data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +62 -0
- data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb +44 -0
- data/src/ruby/pb/grpc/testing/metrics_pb.rb +28 -0
- data/src/ruby/pb/grpc/testing/metrics_services_pb.rb +49 -0
- data/src/ruby/pb/src/proto/grpc/testing/empty_pb.rb +17 -0
- data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +105 -0
- data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +16 -0
- data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +118 -0
- data/src/ruby/pb/test/client.rb +769 -0
- data/src/ruby/pb/test/server.rb +252 -0
- data/src/ruby/pb/test/xds_client.rb +213 -0
- data/src/ruby/spec/call_credentials_spec.rb +42 -0
- data/src/ruby/spec/call_spec.rb +180 -0
- data/src/ruby/spec/channel_connection_spec.rb +126 -0
- data/src/ruby/spec/channel_credentials_spec.rb +82 -0
- data/src/ruby/spec/channel_spec.rb +234 -0
- data/src/ruby/spec/client_auth_spec.rb +126 -0
- data/src/ruby/spec/client_server_spec.rb +664 -0
- data/src/ruby/spec/compression_options_spec.rb +149 -0
- data/src/ruby/spec/debug_message_spec.rb +134 -0
- data/src/ruby/spec/error_sanity_spec.rb +49 -0
- data/src/ruby/spec/errors_spec.rb +142 -0
- data/src/ruby/spec/generic/active_call_spec.rb +672 -0
- data/src/ruby/spec/generic/client_interceptors_spec.rb +153 -0
- data/src/ruby/spec/generic/client_stub_spec.rb +1083 -0
- data/src/ruby/spec/generic/interceptor_registry_spec.rb +65 -0
- data/src/ruby/spec/generic/rpc_desc_spec.rb +374 -0
- data/src/ruby/spec/generic/rpc_server_pool_spec.rb +127 -0
- data/src/ruby/spec/generic/rpc_server_spec.rb +748 -0
- data/src/ruby/spec/generic/server_interceptors_spec.rb +218 -0
- data/src/ruby/spec/generic/service_spec.rb +263 -0
- data/src/ruby/spec/google_rpc_status_utils_spec.rb +282 -0
- data/src/ruby/spec/pb/codegen/grpc/testing/package_options.proto +28 -0
- data/src/ruby/spec/pb/codegen/grpc/testing/package_options_import.proto +22 -0
- data/src/ruby/spec/pb/codegen/grpc/testing/package_options_import2.proto +23 -0
- data/src/ruby/spec/pb/codegen/grpc/testing/package_options_ruby_style.proto +41 -0
- data/src/ruby/spec/pb/codegen/package_option_spec.rb +82 -0
- data/src/ruby/spec/pb/duplicate/codegen_spec.rb +57 -0
- data/src/ruby/spec/pb/health/checker_spec.rb +236 -0
- data/src/ruby/spec/server_credentials_spec.rb +79 -0
- data/src/ruby/spec/server_spec.rb +209 -0
- data/src/ruby/spec/spec_helper.rb +61 -0
- data/src/ruby/spec/support/helpers.rb +107 -0
- data/src/ruby/spec/support/services.rb +160 -0
- data/src/ruby/spec/testdata/README +1 -0
- data/src/ruby/spec/testdata/ca.pem +20 -0
- data/src/ruby/spec/testdata/client.key +28 -0
- data/src/ruby/spec/testdata/client.pem +20 -0
- data/src/ruby/spec/testdata/server1.key +28 -0
- data/src/ruby/spec/testdata/server1.pem +22 -0
- data/src/ruby/spec/time_consts_spec.rb +74 -0
- metadata +394 -0
@@ -0,0 +1,211 @@
|
|
1
|
+
# Copyright 2015 gRPC authors.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require_relative 'client_stub'
|
16
|
+
require_relative 'rpc_desc'
|
17
|
+
|
18
|
+
# GRPC contains the General RPC module.
|
19
|
+
module GRPC
|
20
|
+
# Provides behaviour used to implement schema-derived service classes.
|
21
|
+
#
|
22
|
+
# Is intended to be used to support both client and server
|
23
|
+
# IDL-schema-derived servers.
|
24
|
+
module GenericService
|
25
|
+
# creates a new string that is the underscore separate version of s.
|
26
|
+
#
|
27
|
+
# E.g,
|
28
|
+
# PrintHTML -> print_html
|
29
|
+
# AMethod -> a_method
|
30
|
+
# AnRpc -> an_rpc
|
31
|
+
#
|
32
|
+
# @param s [String] the string to be converted.
|
33
|
+
def self.underscore(s)
|
34
|
+
s = +s # Avoid mutating the argument, as it might be frozen.
|
35
|
+
s.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
36
|
+
s.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
|
37
|
+
s.tr!('-', '_')
|
38
|
+
s.downcase!
|
39
|
+
s
|
40
|
+
end
|
41
|
+
|
42
|
+
# Used to indicate that a name has already been specified
|
43
|
+
class DuplicateRpcName < StandardError
|
44
|
+
def initialize(name)
|
45
|
+
super("rpc (#{name}) is already defined")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Provides a simple DSL to describe RPC services.
|
50
|
+
#
|
51
|
+
# E.g, a Maths service that uses the serializable messages DivArgs,
|
52
|
+
# DivReply and Num might define its endpoint uses the following way:
|
53
|
+
#
|
54
|
+
# rpc :div DivArgs, DivReply # single request, single response
|
55
|
+
# rpc :sum stream(Num), Num # streamed input, single response
|
56
|
+
# rpc :fib FibArgs, stream(Num) # single request, streamed response
|
57
|
+
# rpc :div_many stream(DivArgs), stream(DivReply)
|
58
|
+
# # streamed req and resp
|
59
|
+
#
|
60
|
+
# Each 'rpc' adds an RpcDesc to classes including this module, and
|
61
|
+
# #assert_rpc_descs_have_methods is used to ensure the including class
|
62
|
+
# provides methods with signatures that support all the descriptors.
|
63
|
+
module Dsl
|
64
|
+
# This configures the method names that the serializable message
|
65
|
+
# implementation uses to marshal and unmarshal messages.
|
66
|
+
#
|
67
|
+
# - unmarshal_class method must be a class method on the serializable
|
68
|
+
# message type that takes a string (byte stream) and produces and object
|
69
|
+
#
|
70
|
+
# - marshal_class_method is called on a serializable message instance
|
71
|
+
# and produces a serialized string.
|
72
|
+
#
|
73
|
+
# The Dsl verifies that the types in the descriptor have both the
|
74
|
+
# unmarshal and marshal methods.
|
75
|
+
attr_writer(:marshal_class_method, :unmarshal_class_method)
|
76
|
+
|
77
|
+
# This allows configuration of the service name.
|
78
|
+
attr_accessor(:service_name)
|
79
|
+
|
80
|
+
# Adds an RPC spec.
|
81
|
+
#
|
82
|
+
# Takes the RPC name and the classes representing the types to be
|
83
|
+
# serialized, and adds them to the including classes rpc_desc hash.
|
84
|
+
#
|
85
|
+
# input and output should both have the methods #marshal and #unmarshal
|
86
|
+
# that are responsible for writing and reading an object instance from a
|
87
|
+
# byte buffer respectively.
|
88
|
+
#
|
89
|
+
# @param name [String] the name of the rpc
|
90
|
+
# @param input [Object] the input parameter's class
|
91
|
+
# @param output [Object] the output parameter's class
|
92
|
+
def rpc(name, input, output)
|
93
|
+
fail(DuplicateRpcName, name) if rpc_descs.key? name
|
94
|
+
assert_can_marshal(input)
|
95
|
+
assert_can_marshal(output)
|
96
|
+
rpc_descs[name] = RpcDesc.new(name, input, output,
|
97
|
+
marshal_class_method,
|
98
|
+
unmarshal_class_method)
|
99
|
+
define_method(GenericService.underscore(name.to_s).to_sym) do |*|
|
100
|
+
fail GRPC::BadStatus.new_status_exception(
|
101
|
+
GRPC::Core::StatusCodes::UNIMPLEMENTED)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def inherited(subclass)
|
106
|
+
# Each subclass should have a distinct class variable with its own
|
107
|
+
# rpc_descs
|
108
|
+
subclass.rpc_descs.merge!(rpc_descs)
|
109
|
+
subclass.service_name = service_name
|
110
|
+
end
|
111
|
+
|
112
|
+
# the name of the instance method used to marshal events to a byte
|
113
|
+
# stream.
|
114
|
+
def marshal_class_method
|
115
|
+
@marshal_class_method ||= :marshal
|
116
|
+
end
|
117
|
+
|
118
|
+
# the name of the class method used to unmarshal from a byte stream.
|
119
|
+
def unmarshal_class_method
|
120
|
+
@unmarshal_class_method ||= :unmarshal
|
121
|
+
end
|
122
|
+
|
123
|
+
def assert_can_marshal(cls)
|
124
|
+
cls = cls.type if cls.is_a? RpcDesc::Stream
|
125
|
+
mth = unmarshal_class_method
|
126
|
+
unless cls.methods.include? mth
|
127
|
+
fail(ArgumentError, "#{cls} needs #{cls}.#{mth}")
|
128
|
+
end
|
129
|
+
mth = marshal_class_method
|
130
|
+
return if cls.methods.include? mth
|
131
|
+
fail(ArgumentError, "#{cls} needs #{cls}.#{mth}")
|
132
|
+
end
|
133
|
+
|
134
|
+
# @param cls [Class] the class of a serializable type
|
135
|
+
# @return cls wrapped in a RpcDesc::Stream
|
136
|
+
def stream(cls)
|
137
|
+
assert_can_marshal(cls)
|
138
|
+
RpcDesc::Stream.new(cls)
|
139
|
+
end
|
140
|
+
|
141
|
+
# the RpcDescs defined for this GenericService, keyed by name.
|
142
|
+
def rpc_descs
|
143
|
+
@rpc_descs ||= {}
|
144
|
+
end
|
145
|
+
|
146
|
+
# Creates a rpc client class with methods for accessing the methods
|
147
|
+
# currently in rpc_descs.
|
148
|
+
def rpc_stub_class
|
149
|
+
descs = rpc_descs
|
150
|
+
route_prefix = service_name
|
151
|
+
Class.new(ClientStub) do
|
152
|
+
# @param host [String] the host the stub connects to
|
153
|
+
# @param creds [Core::ChannelCredentials|Symbol] The channel
|
154
|
+
# credentials to use, or :this_channel_is_insecure otherwise
|
155
|
+
# @param kw [KeywordArgs] the channel arguments, plus any optional
|
156
|
+
# args for configuring the client's channel
|
157
|
+
def initialize(host, creds, **kw)
|
158
|
+
super(host, creds, **kw)
|
159
|
+
end
|
160
|
+
|
161
|
+
# Used define_method to add a method for each rpc_desc. Each method
|
162
|
+
# calls the base class method for the given descriptor.
|
163
|
+
descs.each_pair do |name, desc|
|
164
|
+
mth_name = GenericService.underscore(name.to_s).to_sym
|
165
|
+
marshal = desc.marshal_proc
|
166
|
+
unmarshal = desc.unmarshal_proc(:output)
|
167
|
+
route = "/#{route_prefix}/#{name}"
|
168
|
+
if desc.request_response?
|
169
|
+
define_method(mth_name) do |req, metadata = {}|
|
170
|
+
GRPC.logger.debug("calling #{@host}:#{route}")
|
171
|
+
request_response(route, req, marshal, unmarshal, **metadata)
|
172
|
+
end
|
173
|
+
elsif desc.client_streamer?
|
174
|
+
define_method(mth_name) do |reqs, metadata = {}|
|
175
|
+
GRPC.logger.debug("calling #{@host}:#{route}")
|
176
|
+
client_streamer(route, reqs, marshal, unmarshal, **metadata)
|
177
|
+
end
|
178
|
+
elsif desc.server_streamer?
|
179
|
+
define_method(mth_name) do |req, metadata = {}, &blk|
|
180
|
+
GRPC.logger.debug("calling #{@host}:#{route}")
|
181
|
+
server_streamer(route, req, marshal, unmarshal, **metadata, &blk)
|
182
|
+
end
|
183
|
+
else # is a bidi_stream
|
184
|
+
define_method(mth_name) do |reqs, metadata = {}, &blk|
|
185
|
+
GRPC.logger.debug("calling #{@host}:#{route}")
|
186
|
+
bidi_streamer(route, reqs, marshal, unmarshal, **metadata, &blk)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def self.included(o)
|
195
|
+
o.extend(Dsl)
|
196
|
+
# Update to the use the service name including module. Provide a default
|
197
|
+
# that can be nil e.g. when modules are declared dynamically.
|
198
|
+
return unless o.service_name.nil?
|
199
|
+
if o.name.nil?
|
200
|
+
o.service_name = 'GenericService'
|
201
|
+
else
|
202
|
+
modules = o.name.split('::')
|
203
|
+
if modules.length > 2
|
204
|
+
o.service_name = modules[modules.length - 2]
|
205
|
+
else
|
206
|
+
o.service_name = modules.first
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Copyright 2017 gRPC authors.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require_relative './structs'
|
16
|
+
|
17
|
+
# GRPC contains the General RPC module.
|
18
|
+
module GRPC
|
19
|
+
# GoogleRpcStatusUtils provides utilities to convert between a
|
20
|
+
# GRPC::Core::Status and a deserialized Google::Rpc::Status proto
|
21
|
+
# Returns nil if the grpc-status-details-bin trailer could not be
|
22
|
+
# converted to a GoogleRpcStatus due to the server not providing
|
23
|
+
# the necessary trailers.
|
24
|
+
# Raises an error if the server did provide the necessary trailers
|
25
|
+
# but they fail to deseriliaze into a GoogleRpcStatus protobuf.
|
26
|
+
class GoogleRpcStatusUtils
|
27
|
+
def self.extract_google_rpc_status(status)
|
28
|
+
fail ArgumentError, 'bad type' unless status.is_a? Struct::Status
|
29
|
+
grpc_status_details_bin_trailer = 'grpc-status-details-bin'
|
30
|
+
binstatus = status.metadata[grpc_status_details_bin_trailer]
|
31
|
+
return nil if binstatus.nil?
|
32
|
+
|
33
|
+
# Lazily load grpc_c and protobuf_c.so for users of this method.
|
34
|
+
require_relative './grpc'
|
35
|
+
require 'google/rpc/status_pb'
|
36
|
+
|
37
|
+
Google::Rpc::Status.decode(binstatus)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Copyright 2015 gRPC authors.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
begin
|
16
|
+
ruby_version_dirname = /(\d+\.\d+)/.match(RUBY_VERSION).to_s
|
17
|
+
distrib_lib_dir = File.expand_path(ruby_version_dirname,
|
18
|
+
File.dirname(__FILE__))
|
19
|
+
if File.directory?(distrib_lib_dir)
|
20
|
+
require "#{distrib_lib_dir}/grpc_c"
|
21
|
+
else
|
22
|
+
require 'grpc/grpc_c'
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# Copyright 2015 gRPC authors.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
# GRPC contains the General RPC module.
|
16
|
+
module GRPC
|
17
|
+
# DefaultLogger is a module included in GRPC if no other logging is set up for
|
18
|
+
# it. See ../spec/spec_helpers an example of where other logging is added.
|
19
|
+
module DefaultLogger
|
20
|
+
def logger
|
21
|
+
LOGGER
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
# NoopLogger implements the methods of Ruby's conventional logging interface
|
27
|
+
# that are actually used internally within gRPC with a noop implementation.
|
28
|
+
class NoopLogger
|
29
|
+
def info(_ignored)
|
30
|
+
end
|
31
|
+
|
32
|
+
def debug(_ignored)
|
33
|
+
end
|
34
|
+
|
35
|
+
def warn(_ignored)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
LOGGER = NoopLogger.new
|
40
|
+
end
|
41
|
+
|
42
|
+
# Inject the noop #logger if no module-level logger method has been injected.
|
43
|
+
extend DefaultLogger unless methods.include?(:logger)
|
44
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# Copyright 2015 gRPC authors.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
# GRPC contains the General RPC module.
|
16
|
+
module GRPC
|
17
|
+
# Notifier is useful high-level synchronization primitive.
|
18
|
+
class Notifier
|
19
|
+
attr_reader :payload, :notified
|
20
|
+
alias_method :notified?, :notified
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
@mutex = Mutex.new
|
24
|
+
@cvar = ConditionVariable.new
|
25
|
+
@notified = false
|
26
|
+
@payload = nil
|
27
|
+
end
|
28
|
+
|
29
|
+
def wait
|
30
|
+
@mutex.synchronize do
|
31
|
+
@cvar.wait(@mutex) until notified?
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def notify(payload)
|
36
|
+
@mutex.synchronize do
|
37
|
+
return Error.new('already notified') if notified?
|
38
|
+
@payload = payload
|
39
|
+
@notified = true
|
40
|
+
@cvar.signal
|
41
|
+
return nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Copyright 2015 gRPC authors.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
Struct.new('Status', :code, :details, :metadata, :debug_error_string)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Copyright 2015 gRPC authors.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
# GRPC contains the General RPC module.
|
16
|
+
module GRPC
|
17
|
+
VERSION = '1.30.2'
|
18
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
Protocol Buffers
|
2
|
+
================
|
3
|
+
|
4
|
+
This folder contains protocol buffers provided with gRPC ruby, and the generated
|
5
|
+
code to them.
|
6
|
+
|
7
|
+
PREREQUISITES
|
8
|
+
-------------
|
9
|
+
|
10
|
+
The code is generated using the protoc (> 3.0.0.alpha.1) and the
|
11
|
+
grpc_ruby_plugin. These must be installed to regenerate the IDL defined
|
12
|
+
classes, but that's not necessary just to use them.
|
13
|
+
|
14
|
+
health_check/v1
|
15
|
+
--------------------
|
16
|
+
|
17
|
+
This package defines the surface of a simple health check service that gRPC
|
18
|
+
servers may choose to implement, and provides an implementation for it. To
|
19
|
+
re-generate the surface.
|
20
|
+
|
21
|
+
```bash
|
22
|
+
$ # (from this directory)
|
23
|
+
$ protoc -I ../../proto ../../proto/grpc/health/v1/health.proto \
|
24
|
+
--grpc_out=. \
|
25
|
+
--ruby_out=. \
|
26
|
+
--plugin=protoc-gen-grpc=`which grpc_ruby_plugin`
|
27
|
+
```
|
28
|
+
|
29
|
+
test
|
30
|
+
----
|
31
|
+
|
32
|
+
This package defines the surface of the gRPC interop test service and client
|
33
|
+
To re-generate the surface, it's necessary to have checked-out versions of
|
34
|
+
the grpc interop test proto, e.g, by having the full gRPC repository. E.g,
|
35
|
+
|
36
|
+
```bash
|
37
|
+
$ # (from this directory within the grpc repo)
|
38
|
+
$ protoc -I../../.. ../../../test/proto/{messages,test,empty}.proto \
|
39
|
+
--grpc_out=. \
|
40
|
+
--ruby_out=. \
|
41
|
+
--plugin=protoc-gen-grpc=`which grpc_ruby_plugin`
|
42
|
+
```
|