grpc 0.14.1 → 0.15.0
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 +4 -4
- data/Makefile +1398 -817
- data/include/grpc/compression.h +2 -1
- data/include/grpc/grpc.h +10 -1
- data/include/grpc/grpc_cronet.h +51 -0
- data/include/grpc/grpc_posix.h +70 -0
- data/include/grpc/impl/codegen/atm.h +2 -2
- data/include/grpc/impl/codegen/{atm_win32.h → atm_windows.h} +3 -3
- data/include/grpc/impl/codegen/compression_types.h +39 -5
- data/include/grpc/impl/codegen/connectivity_state.h +1 -1
- data/include/grpc/impl/codegen/grpc_types.h +10 -0
- data/include/grpc/impl/codegen/log.h +2 -1
- data/include/grpc/impl/codegen/port_platform.h +30 -12
- data/include/grpc/impl/codegen/slice_buffer.h +2 -3
- data/include/grpc/impl/codegen/sync.h +2 -2
- data/include/grpc/impl/codegen/{sync_win32.h → sync_windows.h} +3 -3
- data/include/grpc/support/{sync_win32.h → atm_windows.h} +4 -4
- data/include/grpc/support/avl.h +5 -0
- data/include/grpc/support/{log_win32.h → log_windows.h} +3 -3
- data/include/grpc/support/string_util.h +2 -1
- data/include/grpc/support/{atm_win32.h → sync_windows.h} +4 -4
- data/src/core/ext/census/gen/census.pb.c +179 -0
- data/src/core/ext/census/gen/census.pb.h +294 -0
- data/src/core/ext/census/grpc_filter.c +11 -7
- data/src/core/ext/client_config/channel_connectivity.c +28 -14
- data/src/core/ext/client_config/client_channel.c +77 -53
- data/src/core/ext/client_config/connector.h +1 -1
- data/src/core/ext/client_config/lb_policy.c +9 -6
- data/src/core/ext/client_config/lb_policy.h +9 -5
- data/src/core/ext/client_config/subchannel.c +58 -39
- data/src/core/ext/client_config/subchannel.h +3 -2
- data/src/core/ext/client_config/subchannel_call_holder.c +34 -19
- data/src/core/ext/client_config/subchannel_call_holder.h +2 -1
- data/src/core/ext/client_config/subchannel_index.c +20 -9
- data/src/core/ext/lb_policy/grpclb/load_balancer_api.c +7 -7
- data/src/core/ext/lb_policy/grpclb/load_balancer_api.h +5 -5
- data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/{v0 → v1}/load_balancer.pb.c +29 -30
- data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +178 -0
- data/src/core/ext/lb_policy/pick_first/pick_first.c +65 -45
- data/src/core/ext/lb_policy/round_robin/round_robin.c +84 -43
- data/src/core/ext/load_reporting/load_reporting.c +133 -0
- data/src/core/ext/load_reporting/load_reporting.h +75 -0
- data/src/core/ext/load_reporting/load_reporting_filter.c +151 -0
- data/src/core/ext/load_reporting/load_reporting_filter.h +41 -0
- data/src/core/ext/resolver/dns/native/dns_resolver.c +22 -8
- data/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +2 -2
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +4 -4
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c +95 -0
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +14 -18
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +49 -24
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +82 -0
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +104 -60
- data/src/core/ext/transport/chttp2/transport/bin_decoder.c +232 -0
- data/src/{ruby/ext/grpc/rb_signal.c → core/ext/transport/chttp2/transport/bin_decoder.h} +27 -31
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +481 -260
- data/src/core/ext/transport/chttp2/transport/frame.h +1 -7
- data/src/core/ext/transport/chttp2/transport/frame_data.c +44 -27
- data/src/core/ext/transport/chttp2/transport/frame_data.h +6 -5
- data/src/core/ext/transport/chttp2/transport/frame_goaway.c +23 -17
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +12 -7
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +3 -3
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +25 -12
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +23 -21
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +17 -9
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +2 -2
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +365 -287
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +8 -6
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +24 -20
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +5 -4
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +1 -0
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +1 -0
- data/src/core/ext/transport/chttp2/transport/internal.h +34 -32
- data/src/core/ext/transport/chttp2/transport/parsing.c +296 -212
- data/src/core/ext/transport/chttp2/transport/writing.c +12 -9
- data/src/core/lib/channel/channel_args.c +26 -12
- data/src/core/lib/channel/channel_args.h +1 -1
- data/src/core/lib/channel/channel_stack.c +12 -8
- data/src/core/lib/channel/channel_stack.h +27 -11
- data/src/core/lib/channel/channel_stack_builder.c +2 -2
- data/src/core/lib/channel/compress_filter.c +26 -31
- data/src/core/lib/channel/compress_filter.h +4 -4
- data/src/core/lib/channel/connected_channel.c +7 -5
- data/src/core/lib/channel/http_client_filter.c +34 -8
- data/src/core/lib/channel/http_client_filter.h +1 -1
- data/src/core/lib/channel/http_server_filter.c +21 -12
- data/src/core/lib/compression/{compression_algorithm.c → compression.c} +22 -21
- data/src/core/lib/http/httpcli.c +81 -59
- data/src/core/lib/http/httpcli.h +11 -15
- data/src/core/lib/http/httpcli_security_connector.c +5 -3
- data/src/core/lib/http/parser.c +127 -118
- data/src/core/lib/http/parser.h +11 -6
- data/src/core/lib/iomgr/closure.c +20 -16
- data/src/core/lib/iomgr/closure.h +19 -15
- data/src/core/lib/iomgr/endpoint.h +1 -1
- data/src/core/lib/iomgr/endpoint_pair_posix.c +2 -2
- data/src/core/lib/iomgr/error.c +535 -0
- data/src/core/lib/iomgr/error.h +192 -0
- data/src/core/lib/iomgr/ev_poll_and_epoll_posix.c +190 -83
- data/src/core/lib/iomgr/ev_poll_posix.c +1267 -0
- data/src/{ruby/ext/grpc/rb_signal.h → core/lib/iomgr/ev_poll_posix.h} +7 -5
- data/src/core/lib/iomgr/ev_posix.c +104 -14
- data/src/core/lib/iomgr/ev_posix.h +17 -7
- data/src/core/lib/iomgr/exec_ctx.c +25 -7
- data/src/core/lib/iomgr/exec_ctx.h +27 -8
- data/src/core/lib/iomgr/executor.c +2 -2
- data/src/core/lib/iomgr/executor.h +1 -1
- data/src/core/lib/iomgr/iocp_windows.c +2 -41
- data/src/core/lib/iomgr/iocp_windows.h +0 -8
- data/src/core/lib/iomgr/iomgr.c +5 -4
- data/src/core/lib/iomgr/iomgr_posix.c +5 -1
- data/src/core/lib/iomgr/iomgr_windows.c +1 -1
- data/src/core/lib/{support → iomgr}/load_file.c +15 -17
- data/src/core/lib/{support → iomgr}/load_file.h +8 -7
- data/src/core/lib/iomgr/polling_entity.c +104 -0
- data/src/core/lib/iomgr/polling_entity.h +81 -0
- data/src/core/lib/iomgr/pollset.h +6 -5
- data/src/core/lib/iomgr/pollset_set_windows.c +4 -1
- data/src/core/lib/iomgr/pollset_windows.c +10 -6
- data/src/core/lib/iomgr/resolve_address.h +5 -9
- data/src/core/lib/iomgr/resolve_address_posix.c +55 -38
- data/src/core/lib/iomgr/resolve_address_windows.c +51 -37
- data/src/core/lib/iomgr/sockaddr.h +2 -2
- data/src/core/lib/iomgr/{sockaddr_win32.h → sockaddr_windows.h} +3 -3
- data/src/core/lib/iomgr/socket_utils_common_posix.c +92 -45
- data/src/core/lib/iomgr/socket_utils_posix.h +19 -12
- data/src/core/lib/iomgr/socket_windows.c +61 -2
- data/src/core/lib/iomgr/socket_windows.h +13 -0
- data/src/core/lib/iomgr/tcp_client_posix.c +54 -39
- data/src/core/lib/iomgr/tcp_client_windows.c +34 -34
- data/src/core/lib/iomgr/tcp_posix.c +43 -39
- data/src/core/lib/iomgr/tcp_server.h +5 -3
- data/src/core/lib/iomgr/tcp_server_posix.c +103 -64
- data/src/core/lib/iomgr/tcp_server_windows.c +114 -101
- data/src/core/lib/iomgr/tcp_windows.c +45 -50
- data/src/core/lib/iomgr/tcp_windows.h +1 -1
- data/src/core/lib/iomgr/timer.c +26 -13
- data/src/core/lib/iomgr/udp_server.c +28 -4
- data/src/core/lib/iomgr/udp_server.h +5 -1
- data/src/core/lib/iomgr/unix_sockets_posix.c +8 -7
- data/src/core/lib/iomgr/unix_sockets_posix.h +2 -1
- data/src/core/lib/iomgr/unix_sockets_posix_noop.c +4 -2
- data/src/core/lib/iomgr/wakeup_fd_eventfd.c +15 -5
- data/src/core/lib/iomgr/wakeup_fd_pipe.c +13 -9
- data/src/core/lib/iomgr/wakeup_fd_posix.c +6 -6
- data/src/core/lib/iomgr/wakeup_fd_posix.h +9 -6
- data/src/core/lib/iomgr/workqueue.h +5 -4
- data/src/core/lib/iomgr/workqueue_posix.c +40 -26
- data/src/core/lib/iomgr/workqueue_windows.c +2 -2
- data/src/core/lib/profiling/basic_timers.c +2 -2
- data/src/core/lib/security/{security_context.c → context/security_context.c} +1 -1
- data/src/core/lib/security/{security_context.h → context/security_context.h} +4 -4
- data/src/core/lib/security/credentials/composite/composite_credentials.c +263 -0
- data/src/core/lib/security/credentials/composite/composite_credentials.h +72 -0
- data/src/core/lib/security/credentials/credentials.c +233 -0
- data/src/core/lib/security/{credentials.h → credentials/credentials.h} +19 -157
- data/src/core/lib/security/{credentials_metadata.c → credentials/credentials_metadata.c} +1 -1
- data/src/core/lib/security/credentials/fake/fake_credentials.c +139 -0
- data/src/core/lib/security/credentials/fake/fake_credentials.h +56 -0
- data/src/core/lib/security/{credentials_posix.c → credentials/google_default/credentials_posix.c} +1 -1
- data/src/core/lib/security/{credentials_win32.c → credentials/google_default/credentials_windows.c} +3 -3
- data/src/core/lib/security/{google_default_credentials.c → credentials/google_default/google_default_credentials.c} +93 -35
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +46 -0
- data/src/core/lib/security/credentials/iam/iam_credentials.c +85 -0
- data/src/core/lib/security/credentials/iam/iam_credentials.h +44 -0
- data/src/core/lib/security/{json_token.c → credentials/jwt/json_token.c} +10 -101
- data/src/core/lib/security/{json_token.h → credentials/jwt/json_token.h} +3 -33
- data/src/core/lib/security/credentials/jwt/jwt_credentials.c +160 -0
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +62 -0
- data/src/core/lib/security/{jwt_verifier.c → credentials/jwt/jwt_verifier.c} +35 -15
- data/src/core/lib/security/{jwt_verifier.h → credentials/jwt/jwt_verifier.h} +3 -3
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +433 -0
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +109 -0
- data/src/core/lib/security/credentials/plugin/plugin_credentials.c +129 -0
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +45 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.c +240 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +48 -0
- data/src/core/lib/security/{auth_filters.h → transport/auth_filters.h} +3 -3
- data/src/core/lib/security/{client_auth_filter.c → transport/client_auth_filter.c} +27 -20
- data/src/core/lib/security/{handshake.c → transport/handshake.c} +77 -45
- data/src/core/lib/security/{handshake.h → transport/handshake.h} +9 -11
- data/src/core/lib/security/{secure_endpoint.c → transport/secure_endpoint.c} +19 -12
- data/src/core/lib/security/{secure_endpoint.h → transport/secure_endpoint.h} +3 -3
- data/src/core/lib/security/{security_connector.c → transport/security_connector.c} +26 -17
- data/src/core/lib/security/{security_connector.h → transport/security_connector.h} +8 -8
- data/src/core/lib/security/{server_auth_filter.c → transport/server_auth_filter.c} +24 -16
- data/src/core/lib/security/transport/tsi_error.c +40 -0
- data/src/core/lib/security/transport/tsi_error.h +42 -0
- data/src/core/lib/security/{b64.c → util/b64.c} +1 -1
- data/src/core/lib/security/{b64.h → util/b64.h} +3 -3
- data/src/core/lib/security/util/json_util.c +61 -0
- data/src/core/lib/security/util/json_util.h +55 -0
- data/src/core/lib/support/avl.c +11 -0
- data/src/core/lib/support/cpu_windows.c +2 -2
- data/src/core/lib/support/{env_win32.c → env_windows.c} +3 -3
- data/src/core/lib/support/log.c +3 -1
- data/src/core/lib/support/log_linux.c +2 -2
- data/src/core/lib/support/{log_win32.c → log_windows.c} +4 -4
- data/src/core/lib/support/murmur_hash.c +3 -5
- data/src/core/lib/support/string.c +10 -0
- data/src/core/lib/support/string.h +4 -0
- data/src/core/lib/support/{string_util_win32.c → string_util_windows.c} +3 -3
- data/src/core/lib/support/{string_win32.c → string_windows.c} +2 -2
- data/src/core/lib/support/{string_win32.h → string_windows.h} +5 -5
- data/src/core/lib/support/subprocess_windows.c +1 -1
- data/src/core/lib/support/{sync_win32.c → sync_windows.c} +2 -2
- data/src/core/lib/support/{thd_win32.c → thd_windows.c} +2 -2
- data/src/core/lib/support/{time_win32.c → time_windows.c} +2 -2
- data/src/core/lib/support/tmpfile_msys.c +1 -1
- data/src/core/lib/support/{tmpfile_win32.c → tmpfile_windows.c} +3 -3
- data/src/core/lib/surface/alarm.c +2 -2
- data/src/core/lib/surface/byte_buffer_reader.c +13 -6
- data/src/core/lib/surface/call.c +323 -123
- data/src/core/lib/surface/call.h +2 -0
- data/src/core/lib/surface/call_log_batch.c +1 -1
- data/src/core/lib/surface/channel.c +64 -15
- data/src/core/lib/surface/channel.h +9 -0
- data/src/core/lib/surface/channel_ping.c +3 -3
- data/src/core/lib/surface/completion_queue.c +75 -19
- data/src/core/lib/surface/completion_queue.h +7 -2
- data/src/core/lib/surface/init.c +2 -1
- data/src/core/lib/surface/init_secure.c +4 -4
- data/src/core/lib/surface/lame_client.c +12 -8
- data/src/core/lib/surface/server.c +213 -120
- data/src/core/lib/surface/server.h +1 -0
- data/src/core/lib/surface/version.c +1 -1
- data/src/core/lib/transport/connectivity_state.c +40 -18
- data/src/core/lib/transport/connectivity_state.h +4 -1
- data/src/core/lib/transport/metadata.c +23 -23
- data/src/core/lib/transport/metadata.h +4 -0
- data/src/core/lib/transport/metadata_batch.c +9 -0
- data/src/core/lib/transport/metadata_batch.h +3 -0
- data/src/core/lib/transport/static_metadata.c +6 -5
- data/src/core/lib/transport/static_metadata.h +64 -60
- data/src/core/lib/transport/transport.c +24 -12
- data/src/core/lib/transport/transport.h +6 -5
- data/src/core/lib/transport/transport_impl.h +4 -0
- data/src/core/lib/transport/transport_op_string.c +2 -2
- data/src/core/plugin_registry/grpc_plugin_registry.c +4 -0
- data/src/ruby/bin/math_services.rb +41 -2
- data/src/ruby/ext/grpc/rb_call.c +42 -40
- data/src/ruby/ext/grpc/rb_channel.c +1 -1
- data/src/ruby/ext/grpc/rb_completion_queue.c +59 -6
- data/src/ruby/ext/grpc/rb_completion_queue.h +1 -1
- data/src/ruby/ext/grpc/rb_grpc.c +1 -3
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +12 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +21 -5
- data/src/ruby/ext/grpc/rb_loader.c +1 -1
- data/src/ruby/ext/grpc/rb_server.c +5 -3
- data/src/ruby/lib/grpc.rb +0 -3
- data/src/ruby/lib/grpc/errors.rb +3 -2
- data/src/ruby/lib/grpc/generic/active_call.rb +32 -42
- data/src/ruby/lib/grpc/generic/bidi_call.rb +20 -0
- data/src/ruby/lib/grpc/generic/client_stub.rb +31 -54
- data/src/ruby/lib/grpc/generic/rpc_desc.rb +4 -4
- data/src/ruby/lib/grpc/generic/rpc_server.rb +12 -23
- data/src/ruby/lib/grpc/generic/service.rb +8 -8
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/v1/health_services.rb +30 -2
- data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services.rb +34 -4
- data/src/ruby/pb/grpc/testing/metrics_services.rb +39 -2
- data/src/ruby/pb/src/proto/grpc/testing/empty.rb +15 -0
- data/src/ruby/pb/src/proto/grpc/testing/messages.rb +84 -0
- data/src/ruby/pb/src/proto/grpc/testing/test.rb +14 -0
- data/src/ruby/pb/src/proto/grpc/testing/test_services.rb +110 -0
- data/src/ruby/pb/test/client.rb +5 -2
- data/src/ruby/spec/generic/active_call_spec.rb +3 -2
- data/src/ruby/spec/generic/client_stub_spec.rb +27 -24
- data/src/ruby/spec/generic/rpc_desc_spec.rb +11 -11
- data/src/ruby/spec/generic/rpc_server_spec.rb +42 -61
- data/src/ruby/spec/pb/health/checker_spec.rb +3 -5
- metadata +86 -48
- data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h +0 -182
- data/src/core/lib/security/credentials.c +0 -1296
- data/src/ruby/lib/grpc/signals.rb +0 -69
@@ -44,21 +44,21 @@ module GRPC
|
|
44
44
|
|
45
45
|
# setup_channel is used by #initialize to constuct a channel from its
|
46
46
|
# arguments.
|
47
|
-
def self.setup_channel(alt_chan, host, creds,
|
47
|
+
def self.setup_channel(alt_chan, host, creds, channel_args = {})
|
48
48
|
unless alt_chan.nil?
|
49
49
|
fail(TypeError, '!Channel') unless alt_chan.is_a?(Core::Channel)
|
50
50
|
return alt_chan
|
51
51
|
end
|
52
|
-
if
|
53
|
-
|
52
|
+
if channel_args['grpc.primary_user_agent'].nil?
|
53
|
+
channel_args['grpc.primary_user_agent'] = ''
|
54
54
|
else
|
55
|
-
|
55
|
+
channel_args['grpc.primary_user_agent'] += ' '
|
56
56
|
end
|
57
|
-
|
57
|
+
channel_args['grpc.primary_user_agent'] += "grpc-ruby/#{VERSION}"
|
58
58
|
unless creds.is_a?(Core::ChannelCredentials) || creds.is_a?(Symbol)
|
59
59
|
fail(TypeError, '!ChannelCredentials or Symbol')
|
60
60
|
end
|
61
|
-
Core::Channel.new(host,
|
61
|
+
Core::Channel.new(host, channel_args, creds)
|
62
62
|
end
|
63
63
|
|
64
64
|
# Allows users of the stub to modify the propagate mask.
|
@@ -96,15 +96,16 @@ module GRPC
|
|
96
96
|
# :this_channel_is_insecure
|
97
97
|
# @param channel_override [Core::Channel] a pre-created channel
|
98
98
|
# @param timeout [Number] the default timeout to use in requests
|
99
|
-
# @param
|
99
|
+
# @param channel_args [Hash] the channel arguments
|
100
100
|
def initialize(host, q, creds,
|
101
101
|
channel_override: nil,
|
102
102
|
timeout: nil,
|
103
103
|
propagate_mask: nil,
|
104
|
-
|
104
|
+
channel_args: {})
|
105
105
|
fail(TypeError, '!CompletionQueue') unless q.is_a?(Core::CompletionQueue)
|
106
|
-
@ch = ClientStub.setup_channel(channel_override, host, creds,
|
107
|
-
|
106
|
+
@ch = ClientStub.setup_channel(channel_override, host, creds,
|
107
|
+
channel_args)
|
108
|
+
alt_host = channel_args[Core::Channel::SSL_TARGET]
|
108
109
|
@host = alt_host.nil? ? host : alt_host
|
109
110
|
@propagate_mask = propagate_mask
|
110
111
|
@timeout = timeout.nil? ? DEFAULT_TIMEOUT : timeout
|
@@ -135,42 +136,35 @@ module GRPC
|
|
135
136
|
# If return_op is true, the call returns an Operation, calling execute
|
136
137
|
# on the Operation returns the response.
|
137
138
|
#
|
138
|
-
# == Keyword Args ==
|
139
|
-
#
|
140
|
-
# Unspecified keyword arguments are treated as metadata to be sent to the
|
141
|
-
# server.
|
142
|
-
#
|
143
139
|
# @param method [String] the RPC method to call on the GRPC server
|
144
140
|
# @param req [Object] the request sent to the server
|
145
141
|
# @param marshal [Function] f(obj)->string that marshals requests
|
146
142
|
# @param unmarshal [Function] f(string)->obj that unmarshals responses
|
147
|
-
# @param timeout [Numeric] (optional) the max completion time in seconds
|
148
143
|
# @param deadline [Time] (optional) the time the request should complete
|
144
|
+
# @param return_op [true|false] return an Operation if true
|
149
145
|
# @param parent [Core::Call] a prior call whose reserved metadata
|
150
146
|
# will be propagated by this one.
|
151
147
|
# @param credentials [Core::CallCredentials] credentials to use when making
|
152
148
|
# the call
|
153
|
-
# @param
|
149
|
+
# @param metadata [Hash] metadata to be sent to the server
|
154
150
|
# @return [Object] the response received from the server
|
155
151
|
def request_response(method, req, marshal, unmarshal,
|
156
152
|
deadline: nil,
|
157
|
-
timeout: nil,
|
158
153
|
return_op: false,
|
159
154
|
parent: nil,
|
160
155
|
credentials: nil,
|
161
|
-
|
156
|
+
metadata: {})
|
162
157
|
c = new_active_call(method, marshal, unmarshal,
|
163
158
|
deadline: deadline,
|
164
|
-
timeout: timeout,
|
165
159
|
parent: parent,
|
166
160
|
credentials: credentials)
|
167
|
-
return c.request_response(req,
|
161
|
+
return c.request_response(req, metadata: metadata) unless return_op
|
168
162
|
|
169
163
|
# return the operation view of the active_call; define #execute as a
|
170
164
|
# new method for this instance that invokes #request_response.
|
171
165
|
op = c.operation
|
172
166
|
op.define_singleton_method(:execute) do
|
173
|
-
c.request_response(req,
|
167
|
+
c.request_response(req, metadata: metadata)
|
174
168
|
end
|
175
169
|
op
|
176
170
|
end
|
@@ -205,42 +199,35 @@ module GRPC
|
|
205
199
|
#
|
206
200
|
# If return_op is true, the call returns the response.
|
207
201
|
#
|
208
|
-
# == Keyword Args ==
|
209
|
-
#
|
210
|
-
# Unspecified keyword arguments are treated as metadata to be sent to the
|
211
|
-
# server.
|
212
|
-
#
|
213
202
|
# @param method [String] the RPC method to call on the GRPC server
|
214
203
|
# @param requests [Object] an Enumerable of requests to send
|
215
204
|
# @param marshal [Function] f(obj)->string that marshals requests
|
216
205
|
# @param unmarshal [Function] f(string)->obj that unmarshals responses
|
217
|
-
# @param timeout [Numeric] (optional) the max completion time in seconds
|
218
206
|
# @param deadline [Time] (optional) the time the request should complete
|
219
207
|
# @param return_op [true|false] return an Operation if true
|
220
208
|
# @param parent [Core::Call] a prior call whose reserved metadata
|
221
209
|
# will be propagated by this one.
|
222
210
|
# @param credentials [Core::CallCredentials] credentials to use when making
|
223
211
|
# the call
|
212
|
+
# @param metadata [Hash] metadata to be sent to the server
|
224
213
|
# @return [Object|Operation] the response received from the server
|
225
214
|
def client_streamer(method, requests, marshal, unmarshal,
|
226
215
|
deadline: nil,
|
227
|
-
timeout: nil,
|
228
216
|
return_op: false,
|
229
217
|
parent: nil,
|
230
218
|
credentials: nil,
|
231
|
-
|
219
|
+
metadata: {})
|
232
220
|
c = new_active_call(method, marshal, unmarshal,
|
233
221
|
deadline: deadline,
|
234
|
-
timeout: timeout,
|
235
222
|
parent: parent,
|
236
223
|
credentials: credentials)
|
237
|
-
return c.client_streamer(requests,
|
224
|
+
return c.client_streamer(requests, metadata: metadata) unless return_op
|
238
225
|
|
239
226
|
# return the operation view of the active_call; define #execute as a
|
240
227
|
# new method for this instance that invokes #client_streamer.
|
241
228
|
op = c.operation
|
242
229
|
op.define_singleton_method(:execute) do
|
243
|
-
c.client_streamer(requests,
|
230
|
+
c.client_streamer(requests, metadata: metadata)
|
244
231
|
end
|
245
232
|
op
|
246
233
|
end
|
@@ -292,35 +279,33 @@ module GRPC
|
|
292
279
|
# @param req [Object] the request sent to the server
|
293
280
|
# @param marshal [Function] f(obj)->string that marshals requests
|
294
281
|
# @param unmarshal [Function] f(string)->obj that unmarshals responses
|
295
|
-
# @param timeout [Numeric] (optional) the max completion time in seconds
|
296
282
|
# @param deadline [Time] (optional) the time the request should complete
|
297
283
|
# @param return_op [true|false]return an Operation if true
|
298
284
|
# @param parent [Core::Call] a prior call whose reserved metadata
|
299
285
|
# will be propagated by this one.
|
300
286
|
# @param credentials [Core::CallCredentials] credentials to use when making
|
301
287
|
# the call
|
288
|
+
# @param metadata [Hash] metadata to be sent to the server
|
302
289
|
# @param blk [Block] when provided, is executed for each response
|
303
290
|
# @return [Enumerator|Operation|nil] as discussed above
|
304
291
|
def server_streamer(method, req, marshal, unmarshal,
|
305
292
|
deadline: nil,
|
306
|
-
timeout: nil,
|
307
293
|
return_op: false,
|
308
294
|
parent: nil,
|
309
295
|
credentials: nil,
|
310
|
-
|
296
|
+
metadata: {},
|
311
297
|
&blk)
|
312
298
|
c = new_active_call(method, marshal, unmarshal,
|
313
299
|
deadline: deadline,
|
314
|
-
timeout: timeout,
|
315
300
|
parent: parent,
|
316
301
|
credentials: credentials)
|
317
|
-
return c.server_streamer(req,
|
302
|
+
return c.server_streamer(req, metadata: metadata, &blk) unless return_op
|
318
303
|
|
319
304
|
# return the operation view of the active_call; define #execute
|
320
305
|
# as a new method for this instance that invokes #server_streamer
|
321
306
|
op = c.operation
|
322
307
|
op.define_singleton_method(:execute) do
|
323
|
-
c.server_streamer(req,
|
308
|
+
c.server_streamer(req, metadata: metadata, &blk)
|
324
309
|
end
|
325
310
|
op
|
326
311
|
end
|
@@ -391,11 +376,6 @@ module GRPC
|
|
391
376
|
# * the deadline is exceeded
|
392
377
|
#
|
393
378
|
#
|
394
|
-
# == Keyword Args ==
|
395
|
-
#
|
396
|
-
# Unspecified keyword arguments are treated as metadata to be sent to the
|
397
|
-
# server.
|
398
|
-
#
|
399
379
|
# == Return Value ==
|
400
380
|
#
|
401
381
|
# if the return_op is false, the return value is an Enumerator of the
|
@@ -411,36 +391,35 @@ module GRPC
|
|
411
391
|
# @param requests [Object] an Enumerable of requests to send
|
412
392
|
# @param marshal [Function] f(obj)->string that marshals requests
|
413
393
|
# @param unmarshal [Function] f(string)->obj that unmarshals responses
|
414
|
-
# @param timeout [Numeric] (optional) the max completion time in seconds
|
415
394
|
# @param deadline [Time] (optional) the time the request should complete
|
416
395
|
# @param parent [Core::Call] a prior call whose reserved metadata
|
417
396
|
# will be propagated by this one.
|
418
397
|
# @param credentials [Core::CallCredentials] credentials to use when making
|
419
398
|
# the call
|
420
399
|
# @param return_op [true|false] return an Operation if true
|
400
|
+
# @param metadata [Hash] metadata to be sent to the server
|
421
401
|
# @param blk [Block] when provided, is executed for each response
|
422
402
|
# @return [Enumerator|nil|Operation] as discussed above
|
423
403
|
def bidi_streamer(method, requests, marshal, unmarshal,
|
424
404
|
deadline: nil,
|
425
|
-
timeout: nil,
|
426
405
|
return_op: false,
|
427
406
|
parent: nil,
|
428
407
|
credentials: nil,
|
429
|
-
|
408
|
+
metadata: {},
|
430
409
|
&blk)
|
431
410
|
c = new_active_call(method, marshal, unmarshal,
|
432
411
|
deadline: deadline,
|
433
|
-
timeout: timeout,
|
434
412
|
parent: parent,
|
435
413
|
credentials: credentials)
|
436
414
|
|
437
|
-
return c.bidi_streamer(requests,
|
415
|
+
return c.bidi_streamer(requests, metadata: metadata,
|
416
|
+
&blk) unless return_op
|
438
417
|
|
439
418
|
# return the operation view of the active_call; define #execute
|
440
419
|
# as a new method for this instance that invokes #bidi_streamer
|
441
420
|
op = c.operation
|
442
421
|
op.define_singleton_method(:execute) do
|
443
|
-
c.bidi_streamer(requests,
|
422
|
+
c.bidi_streamer(requests, metadata: metadata, &blk)
|
444
423
|
end
|
445
424
|
op
|
446
425
|
end
|
@@ -457,12 +436,10 @@ module GRPC
|
|
457
436
|
# @param timeout [TimeConst]
|
458
437
|
def new_active_call(method, marshal, unmarshal,
|
459
438
|
deadline: nil,
|
460
|
-
timeout: nil,
|
461
439
|
parent: nil,
|
462
440
|
credentials: nil)
|
463
|
-
|
464
|
-
|
465
|
-
end
|
441
|
+
|
442
|
+
deadline = from_relative_time(@timeout) if deadline.nil?
|
466
443
|
# Provide each new client call with its own completion queue
|
467
444
|
call_queue = Core::CompletionQueue.new
|
468
445
|
call = @ch.create_call(call_queue,
|
@@ -80,12 +80,12 @@ module GRPC
|
|
80
80
|
else # is a bidi_stream
|
81
81
|
active_call.run_server_bidi(mth)
|
82
82
|
end
|
83
|
-
send_status(active_call, OK, 'OK',
|
83
|
+
send_status(active_call, OK, 'OK', active_call.output_metadata)
|
84
84
|
rescue BadStatus => e
|
85
85
|
# this is raised by handlers that want GRPC to send an application error
|
86
86
|
# code and detail message and some additional app-specific metadata.
|
87
87
|
GRPC.logger.debug("app err:#{active_call}, status:#{e.code}:#{e.details}")
|
88
|
-
send_status(active_call, e.code, e.details,
|
88
|
+
send_status(active_call, e.code, e.details, e.metadata)
|
89
89
|
rescue Core::CallError => e
|
90
90
|
# This is raised by GRPC internals but should rarely, if ever happen.
|
91
91
|
# Log it, but don't notify the other endpoint..
|
@@ -135,10 +135,10 @@ module GRPC
|
|
135
135
|
"##{mth.name}: bad arg count; got:#{mth.arity}, want:#{want}, #{msg}"
|
136
136
|
end
|
137
137
|
|
138
|
-
def send_status(active_client, code, details,
|
138
|
+
def send_status(active_client, code, details, metadata = {})
|
139
139
|
details = 'Not sure why' if details.nil?
|
140
140
|
GRPC.logger.debug("Sending status #{code}:#{details}")
|
141
|
-
active_client.send_status(code, details, code == OK,
|
141
|
+
active_client.send_status(code, details, code == OK, metadata: metadata)
|
142
142
|
rescue StandardError => e
|
143
143
|
GRPC.logger.warn("Could not send status #{code}:#{details}")
|
144
144
|
GRPC.logger.warn(e)
|
@@ -28,7 +28,6 @@
|
|
28
28
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
29
|
|
30
30
|
require_relative '../grpc'
|
31
|
-
require_relative '../signals'
|
32
31
|
require_relative 'active_call'
|
33
32
|
require_relative 'service'
|
34
33
|
require 'thread'
|
@@ -170,14 +169,6 @@ module GRPC
|
|
170
169
|
alt_cq
|
171
170
|
end
|
172
171
|
|
173
|
-
# setup_srv is used by #initialize to constuct a Core::Server from its
|
174
|
-
# arguments.
|
175
|
-
def self.setup_srv(alt_srv, cq, **kw)
|
176
|
-
return Core::Server.new(cq, kw) if alt_srv.nil?
|
177
|
-
fail(TypeError, '!Server') unless alt_srv.is_a? Core::Server
|
178
|
-
alt_srv
|
179
|
-
end
|
180
|
-
|
181
172
|
# setup_connect_md_proc is used by #initialize to validate the
|
182
173
|
# connect_md_proc.
|
183
174
|
def self.setup_connect_md_proc(a_proc)
|
@@ -194,9 +185,6 @@ module GRPC
|
|
194
185
|
# instance, however other arbitrary are allowed and when present are used
|
195
186
|
# to configure the listeninng connection set up by the RpcServer.
|
196
187
|
#
|
197
|
-
# * server_override: which if passed must be a [GRPC::Core::Server]. When
|
198
|
-
# present.
|
199
|
-
#
|
200
188
|
# * poll_period: when present, the server polls for new events with this
|
201
189
|
# period
|
202
190
|
#
|
@@ -218,13 +206,15 @@ module GRPC
|
|
218
206
|
# when non-nil is a proc for determining metadata to to send back the client
|
219
207
|
# on receiving an invocation req. The proc signature is:
|
220
208
|
# {key: val, ..} func(method_name, {key: val, ...})
|
209
|
+
#
|
210
|
+
# * server_args:
|
211
|
+
# A server arguments hash to be passed down to the underlying core server
|
221
212
|
def initialize(pool_size:DEFAULT_POOL_SIZE,
|
222
213
|
max_waiting_requests:DEFAULT_MAX_WAITING_REQUESTS,
|
223
214
|
poll_period:DEFAULT_POLL_PERIOD,
|
224
215
|
completion_queue_override:nil,
|
225
|
-
server_override:nil,
|
226
216
|
connect_md_proc:nil,
|
227
|
-
|
217
|
+
server_args:{})
|
228
218
|
@connect_md_proc = RpcServer.setup_connect_md_proc(connect_md_proc)
|
229
219
|
@cq = RpcServer.setup_cq(completion_queue_override)
|
230
220
|
@max_waiting_requests = max_waiting_requests
|
@@ -236,7 +226,7 @@ module GRPC
|
|
236
226
|
# running_state can take 4 values: :not_started, :running, :stopping, and
|
237
227
|
# :stopped. State transitions can only proceed in that order.
|
238
228
|
@running_state = :not_started
|
239
|
-
@server =
|
229
|
+
@server = Core::Server.new(@cq, server_args)
|
240
230
|
end
|
241
231
|
|
242
232
|
# stops a running server
|
@@ -353,10 +343,7 @@ module GRPC
|
|
353
343
|
transition_running_state(:running)
|
354
344
|
@run_cond.broadcast
|
355
345
|
end
|
356
|
-
remove_signal_handler = GRPC::Signals.register_handler { stop }
|
357
346
|
loop_handle_server_calls
|
358
|
-
# Remove signal handler when server stops
|
359
|
-
remove_signal_handler.call
|
360
347
|
end
|
361
348
|
|
362
349
|
alias_method :run_till_terminated, :run
|
@@ -368,7 +355,7 @@ module GRPC
|
|
368
355
|
return an_rpc if @pool.jobs_waiting <= @max_waiting_requests
|
369
356
|
GRPC.logger.warn("NOT AVAILABLE: too many jobs_waiting: #{an_rpc}")
|
370
357
|
noop = proc { |x| x }
|
371
|
-
c = ActiveCall.new(an_rpc.call,
|
358
|
+
c = ActiveCall.new(an_rpc.call, an_rpc.cq, noop, noop, an_rpc.deadline)
|
372
359
|
c.send_status(GRPC::Core::StatusCodes::RESOURCE_EXHAUSTED, '')
|
373
360
|
nil
|
374
361
|
end
|
@@ -379,7 +366,7 @@ module GRPC
|
|
379
366
|
return an_rpc if rpc_descs.key?(mth)
|
380
367
|
GRPC.logger.warn("UNIMPLEMENTED: #{an_rpc}")
|
381
368
|
noop = proc { |x| x }
|
382
|
-
c = ActiveCall.new(an_rpc.call,
|
369
|
+
c = ActiveCall.new(an_rpc.call, an_rpc.cq, noop, noop, an_rpc.deadline)
|
383
370
|
c.send_status(GRPC::Core::StatusCodes::UNIMPLEMENTED, '')
|
384
371
|
nil
|
385
372
|
end
|
@@ -390,7 +377,8 @@ module GRPC
|
|
390
377
|
loop_tag = Object.new
|
391
378
|
while running_state == :running
|
392
379
|
begin
|
393
|
-
|
380
|
+
comp_queue = Core::CompletionQueue.new
|
381
|
+
an_rpc = @server.request_call(comp_queue, loop_tag, INFINITE_FUTURE)
|
394
382
|
break if (!an_rpc.nil?) && an_rpc.call.nil?
|
395
383
|
active_call = new_active_server_call(an_rpc)
|
396
384
|
unless active_call.nil?
|
@@ -429,15 +417,16 @@ module GRPC
|
|
429
417
|
unless @connect_md_proc.nil?
|
430
418
|
connect_md = @connect_md_proc.call(an_rpc.method, an_rpc.metadata)
|
431
419
|
end
|
432
|
-
an_rpc.call.run_batch(
|
420
|
+
an_rpc.call.run_batch(an_rpc.cq, handle_call_tag, INFINITE_FUTURE,
|
433
421
|
SEND_INITIAL_METADATA => connect_md)
|
422
|
+
|
434
423
|
return nil unless available?(an_rpc)
|
435
424
|
return nil unless implemented?(an_rpc)
|
436
425
|
|
437
426
|
# Create the ActiveCall
|
438
427
|
GRPC.logger.info("deadline is #{an_rpc.deadline}; (now=#{Time.now})")
|
439
428
|
rpc_desc = rpc_descs[an_rpc.method.to_sym]
|
440
|
-
c = ActiveCall.new(an_rpc.call,
|
429
|
+
c = ActiveCall.new(an_rpc.call, an_rpc.cq,
|
441
430
|
rpc_desc.marshal_proc, rpc_desc.unmarshal_proc(:input),
|
442
431
|
an_rpc.deadline)
|
443
432
|
mth = an_rpc.method.to_sym
|
@@ -179,24 +179,24 @@ module GRPC
|
|
179
179
|
unmarshal = desc.unmarshal_proc(:output)
|
180
180
|
route = "/#{route_prefix}/#{name}"
|
181
181
|
if desc.request_response?
|
182
|
-
define_method(mth_name) do |req,
|
182
|
+
define_method(mth_name) do |req, metadata = {}|
|
183
183
|
GRPC.logger.debug("calling #{@host}:#{route}")
|
184
|
-
request_response(route, req, marshal, unmarshal,
|
184
|
+
request_response(route, req, marshal, unmarshal, metadata)
|
185
185
|
end
|
186
186
|
elsif desc.client_streamer?
|
187
|
-
define_method(mth_name) do |reqs,
|
187
|
+
define_method(mth_name) do |reqs, metadata = {}|
|
188
188
|
GRPC.logger.debug("calling #{@host}:#{route}")
|
189
|
-
client_streamer(route, reqs, marshal, unmarshal,
|
189
|
+
client_streamer(route, reqs, marshal, unmarshal, metadata)
|
190
190
|
end
|
191
191
|
elsif desc.server_streamer?
|
192
|
-
define_method(mth_name) do |req,
|
192
|
+
define_method(mth_name) do |req, metadata = {}, &blk|
|
193
193
|
GRPC.logger.debug("calling #{@host}:#{route}")
|
194
|
-
server_streamer(route, req, marshal, unmarshal,
|
194
|
+
server_streamer(route, req, marshal, unmarshal, metadata, &blk)
|
195
195
|
end
|
196
196
|
else # is a bidi_stream
|
197
|
-
define_method(mth_name) do |reqs,
|
197
|
+
define_method(mth_name) do |reqs, metadata = {}, &blk|
|
198
198
|
GRPC.logger.debug("calling #{@host}:#{route}")
|
199
|
-
bidi_streamer(route, reqs, marshal, unmarshal,
|
199
|
+
bidi_streamer(route, reqs, marshal, unmarshal, metadata, &blk)
|
200
200
|
end
|
201
201
|
end
|
202
202
|
end
|
@@ -1,5 +1,35 @@
|
|
1
1
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
2
|
# Source: grpc/health/v1/health.proto for package 'grpc.health.v1'
|
3
|
+
# Original file comments:
|
4
|
+
# Copyright 2015, Google Inc.
|
5
|
+
# All rights reserved.
|
6
|
+
#
|
7
|
+
# Redistribution and use in source and binary forms, with or without
|
8
|
+
# modification, are permitted provided that the following conditions are
|
9
|
+
# met:
|
10
|
+
#
|
11
|
+
# * Redistributions of source code must retain the above copyright
|
12
|
+
# notice, this list of conditions and the following disclaimer.
|
13
|
+
# * Redistributions in binary form must reproduce the above
|
14
|
+
# copyright notice, this list of conditions and the following disclaimer
|
15
|
+
# in the documentation and/or other materials provided with the
|
16
|
+
# distribution.
|
17
|
+
# * Neither the name of Google Inc. nor the names of its
|
18
|
+
# contributors may be used to endorse or promote products derived from
|
19
|
+
# this software without specific prior written permission.
|
20
|
+
#
|
21
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
22
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
23
|
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
24
|
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
25
|
+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
26
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
27
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
28
|
+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
29
|
+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
30
|
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
31
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
|
+
#
|
3
33
|
|
4
34
|
require 'grpc'
|
5
35
|
require 'grpc/health/v1/health'
|
@@ -8,8 +38,6 @@ module Grpc
|
|
8
38
|
module Health
|
9
39
|
module V1
|
10
40
|
module Health
|
11
|
-
|
12
|
-
# TODO: add proto service documentation here
|
13
41
|
class Service
|
14
42
|
|
15
43
|
include GRPC::GenericService
|