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
@@ -46,7 +46,7 @@ grpc_completion_queue *grpc_rb_get_wrapped_completion_queue(VALUE v);
|
|
46
46
|
*
|
47
47
|
* This avoids having code that holds the GIL repeated at multiple sites.
|
48
48
|
*/
|
49
|
-
grpc_event grpc_rb_completion_queue_pluck_event(VALUE
|
49
|
+
grpc_event grpc_rb_completion_queue_pluck_event(VALUE self, VALUE tag,
|
50
50
|
VALUE timeout);
|
51
51
|
|
52
52
|
/* Initializes the CompletionQueue class. */
|
data/src/ruby/ext/grpc/rb_grpc.c
CHANGED
@@ -50,7 +50,6 @@
|
|
50
50
|
#include "rb_loader.h"
|
51
51
|
#include "rb_server.h"
|
52
52
|
#include "rb_server_credentials.h"
|
53
|
-
#include "rb_signal.h"
|
54
53
|
|
55
54
|
static VALUE grpc_rb_cTimeVal = Qnil;
|
56
55
|
|
@@ -319,7 +318,7 @@ void Init_grpc_c() {
|
|
319
318
|
grpc_rb_mGrpcCore = rb_define_module_under(grpc_rb_mGRPC, "Core");
|
320
319
|
grpc_rb_sNewServerRpc =
|
321
320
|
rb_struct_define("NewServerRpc", "method", "host",
|
322
|
-
"deadline", "metadata", "call", NULL);
|
321
|
+
"deadline", "metadata", "call", "cq", NULL);
|
323
322
|
grpc_rb_sStatus =
|
324
323
|
rb_struct_define("Status", "code", "details", "metadata", NULL);
|
325
324
|
sym_code = ID2SYM(rb_intern("code"));
|
@@ -333,7 +332,6 @@ void Init_grpc_c() {
|
|
333
332
|
Init_grpc_channel_credentials();
|
334
333
|
Init_grpc_server();
|
335
334
|
Init_grpc_server_credentials();
|
336
|
-
Init_grpc_signals();
|
337
335
|
Init_grpc_status_codes();
|
338
336
|
Init_grpc_time_consts();
|
339
337
|
}
|
@@ -33,7 +33,7 @@
|
|
33
33
|
|
34
34
|
#include <grpc/support/port_platform.h>
|
35
35
|
|
36
|
-
#ifdef
|
36
|
+
#ifdef GPR_WINDOWS
|
37
37
|
|
38
38
|
#include "rb_grpc_imports.generated.h"
|
39
39
|
|
@@ -115,6 +115,7 @@ grpc_server_register_method_type grpc_server_register_method_import;
|
|
115
115
|
grpc_server_request_registered_call_type grpc_server_request_registered_call_import;
|
116
116
|
grpc_server_create_type grpc_server_create_import;
|
117
117
|
grpc_server_register_completion_queue_type grpc_server_register_completion_queue_import;
|
118
|
+
grpc_server_register_non_listening_completion_queue_type grpc_server_register_non_listening_completion_queue_import;
|
118
119
|
grpc_server_add_insecure_http2_port_type grpc_server_add_insecure_http2_port_import;
|
119
120
|
grpc_server_start_type grpc_server_start_import;
|
120
121
|
grpc_server_shutdown_and_notify_type grpc_server_shutdown_and_notify_import;
|
@@ -125,6 +126,8 @@ grpc_header_key_is_legal_type grpc_header_key_is_legal_import;
|
|
125
126
|
grpc_header_nonbin_value_is_legal_type grpc_header_nonbin_value_is_legal_import;
|
126
127
|
grpc_is_binary_header_type grpc_is_binary_header_import;
|
127
128
|
grpc_call_error_to_string_type grpc_call_error_to_string_import;
|
129
|
+
grpc_insecure_channel_create_from_fd_type grpc_insecure_channel_create_from_fd_import;
|
130
|
+
grpc_server_add_insecure_channel_from_fd_type grpc_server_add_insecure_channel_from_fd_import;
|
128
131
|
grpc_auth_property_iterator_next_type grpc_auth_property_iterator_next_import;
|
129
132
|
grpc_auth_context_property_iterator_type grpc_auth_context_property_iterator_import;
|
130
133
|
grpc_auth_context_peer_identity_type grpc_auth_context_peer_identity_import;
|
@@ -257,6 +260,8 @@ gpr_avl_unref_type gpr_avl_unref_import;
|
|
257
260
|
gpr_avl_add_type gpr_avl_add_import;
|
258
261
|
gpr_avl_remove_type gpr_avl_remove_import;
|
259
262
|
gpr_avl_get_type gpr_avl_get_import;
|
263
|
+
gpr_avl_maybe_get_type gpr_avl_maybe_get_import;
|
264
|
+
gpr_avl_is_empty_type gpr_avl_is_empty_import;
|
260
265
|
gpr_cmdline_create_type gpr_cmdline_create_import;
|
261
266
|
gpr_cmdline_add_int_type gpr_cmdline_add_int_import;
|
262
267
|
gpr_cmdline_add_flag_type gpr_cmdline_add_flag_import;
|
@@ -381,6 +386,7 @@ void grpc_rb_load_imports(HMODULE library) {
|
|
381
386
|
grpc_server_request_registered_call_import = (grpc_server_request_registered_call_type) GetProcAddress(library, "grpc_server_request_registered_call");
|
382
387
|
grpc_server_create_import = (grpc_server_create_type) GetProcAddress(library, "grpc_server_create");
|
383
388
|
grpc_server_register_completion_queue_import = (grpc_server_register_completion_queue_type) GetProcAddress(library, "grpc_server_register_completion_queue");
|
389
|
+
grpc_server_register_non_listening_completion_queue_import = (grpc_server_register_non_listening_completion_queue_type) GetProcAddress(library, "grpc_server_register_non_listening_completion_queue");
|
384
390
|
grpc_server_add_insecure_http2_port_import = (grpc_server_add_insecure_http2_port_type) GetProcAddress(library, "grpc_server_add_insecure_http2_port");
|
385
391
|
grpc_server_start_import = (grpc_server_start_type) GetProcAddress(library, "grpc_server_start");
|
386
392
|
grpc_server_shutdown_and_notify_import = (grpc_server_shutdown_and_notify_type) GetProcAddress(library, "grpc_server_shutdown_and_notify");
|
@@ -391,6 +397,8 @@ void grpc_rb_load_imports(HMODULE library) {
|
|
391
397
|
grpc_header_nonbin_value_is_legal_import = (grpc_header_nonbin_value_is_legal_type) GetProcAddress(library, "grpc_header_nonbin_value_is_legal");
|
392
398
|
grpc_is_binary_header_import = (grpc_is_binary_header_type) GetProcAddress(library, "grpc_is_binary_header");
|
393
399
|
grpc_call_error_to_string_import = (grpc_call_error_to_string_type) GetProcAddress(library, "grpc_call_error_to_string");
|
400
|
+
grpc_insecure_channel_create_from_fd_import = (grpc_insecure_channel_create_from_fd_type) GetProcAddress(library, "grpc_insecure_channel_create_from_fd");
|
401
|
+
grpc_server_add_insecure_channel_from_fd_import = (grpc_server_add_insecure_channel_from_fd_type) GetProcAddress(library, "grpc_server_add_insecure_channel_from_fd");
|
394
402
|
grpc_auth_property_iterator_next_import = (grpc_auth_property_iterator_next_type) GetProcAddress(library, "grpc_auth_property_iterator_next");
|
395
403
|
grpc_auth_context_property_iterator_import = (grpc_auth_context_property_iterator_type) GetProcAddress(library, "grpc_auth_context_property_iterator");
|
396
404
|
grpc_auth_context_peer_identity_import = (grpc_auth_context_peer_identity_type) GetProcAddress(library, "grpc_auth_context_peer_identity");
|
@@ -523,6 +531,8 @@ void grpc_rb_load_imports(HMODULE library) {
|
|
523
531
|
gpr_avl_add_import = (gpr_avl_add_type) GetProcAddress(library, "gpr_avl_add");
|
524
532
|
gpr_avl_remove_import = (gpr_avl_remove_type) GetProcAddress(library, "gpr_avl_remove");
|
525
533
|
gpr_avl_get_import = (gpr_avl_get_type) GetProcAddress(library, "gpr_avl_get");
|
534
|
+
gpr_avl_maybe_get_import = (gpr_avl_maybe_get_type) GetProcAddress(library, "gpr_avl_maybe_get");
|
535
|
+
gpr_avl_is_empty_import = (gpr_avl_is_empty_type) GetProcAddress(library, "gpr_avl_is_empty");
|
526
536
|
gpr_cmdline_create_import = (gpr_cmdline_create_type) GetProcAddress(library, "gpr_cmdline_create");
|
527
537
|
gpr_cmdline_add_int_import = (gpr_cmdline_add_int_type) GetProcAddress(library, "gpr_cmdline_add_int");
|
528
538
|
gpr_cmdline_add_flag_import = (gpr_cmdline_add_flag_type) GetProcAddress(library, "gpr_cmdline_add_flag");
|
@@ -569,4 +579,4 @@ void grpc_rb_load_imports(HMODULE library) {
|
|
569
579
|
gpr_thd_join_import = (gpr_thd_join_type) GetProcAddress(library, "gpr_thd_join");
|
570
580
|
}
|
571
581
|
|
572
|
-
#endif /*
|
582
|
+
#endif /* GPR_WINDOWS */
|
@@ -36,13 +36,14 @@
|
|
36
36
|
|
37
37
|
#include <grpc/support/port_platform.h>
|
38
38
|
|
39
|
-
#ifdef
|
39
|
+
#ifdef GPR_WINDOWS
|
40
40
|
|
41
41
|
#include <windows.h>
|
42
42
|
|
43
43
|
#include <grpc/census.h>
|
44
44
|
#include <grpc/compression.h>
|
45
45
|
#include <grpc/grpc.h>
|
46
|
+
#include <grpc/grpc_posix.h>
|
46
47
|
#include <grpc/grpc_security.h>
|
47
48
|
#include <grpc/impl/codegen/alloc.h>
|
48
49
|
#include <grpc/impl/codegen/byte_buffer.h>
|
@@ -56,7 +57,7 @@
|
|
56
57
|
#include <grpc/support/cpu.h>
|
57
58
|
#include <grpc/support/histogram.h>
|
58
59
|
#include <grpc/support/host_port.h>
|
59
|
-
#include <grpc/support/
|
60
|
+
#include <grpc/support/log_windows.h>
|
60
61
|
#include <grpc/support/string_util.h>
|
61
62
|
#include <grpc/support/subprocess.h>
|
62
63
|
#include <grpc/support/thd.h>
|
@@ -295,6 +296,9 @@ extern grpc_server_create_type grpc_server_create_import;
|
|
295
296
|
typedef void(*grpc_server_register_completion_queue_type)(grpc_server *server, grpc_completion_queue *cq, void *reserved);
|
296
297
|
extern grpc_server_register_completion_queue_type grpc_server_register_completion_queue_import;
|
297
298
|
#define grpc_server_register_completion_queue grpc_server_register_completion_queue_import
|
299
|
+
typedef void(*grpc_server_register_non_listening_completion_queue_type)(grpc_server *server, grpc_completion_queue *q, void *reserved);
|
300
|
+
extern grpc_server_register_non_listening_completion_queue_type grpc_server_register_non_listening_completion_queue_import;
|
301
|
+
#define grpc_server_register_non_listening_completion_queue grpc_server_register_non_listening_completion_queue_import
|
298
302
|
typedef int(*grpc_server_add_insecure_http2_port_type)(grpc_server *server, const char *addr);
|
299
303
|
extern grpc_server_add_insecure_http2_port_type grpc_server_add_insecure_http2_port_import;
|
300
304
|
#define grpc_server_add_insecure_http2_port grpc_server_add_insecure_http2_port_import
|
@@ -325,6 +329,12 @@ extern grpc_is_binary_header_type grpc_is_binary_header_import;
|
|
325
329
|
typedef const char *(*grpc_call_error_to_string_type)(grpc_call_error error);
|
326
330
|
extern grpc_call_error_to_string_type grpc_call_error_to_string_import;
|
327
331
|
#define grpc_call_error_to_string grpc_call_error_to_string_import
|
332
|
+
typedef grpc_channel *(*grpc_insecure_channel_create_from_fd_type)(const char *target, int fd, const grpc_channel_args *args);
|
333
|
+
extern grpc_insecure_channel_create_from_fd_type grpc_insecure_channel_create_from_fd_import;
|
334
|
+
#define grpc_insecure_channel_create_from_fd grpc_insecure_channel_create_from_fd_import
|
335
|
+
typedef void(*grpc_server_add_insecure_channel_from_fd_type)(grpc_server *server, grpc_completion_queue *cq, int fd);
|
336
|
+
extern grpc_server_add_insecure_channel_from_fd_type grpc_server_add_insecure_channel_from_fd_import;
|
337
|
+
#define grpc_server_add_insecure_channel_from_fd grpc_server_add_insecure_channel_from_fd_import
|
328
338
|
typedef const grpc_auth_property *(*grpc_auth_property_iterator_next_type)(grpc_auth_property_iterator *it);
|
329
339
|
extern grpc_auth_property_iterator_next_type grpc_auth_property_iterator_next_import;
|
330
340
|
#define grpc_auth_property_iterator_next grpc_auth_property_iterator_next_import
|
@@ -472,7 +482,7 @@ extern grpc_byte_buffer_reader_readall_type grpc_byte_buffer_reader_readall_impo
|
|
472
482
|
typedef grpc_byte_buffer *(*grpc_raw_byte_buffer_from_reader_type)(grpc_byte_buffer_reader *reader);
|
473
483
|
extern grpc_raw_byte_buffer_from_reader_type grpc_raw_byte_buffer_from_reader_import;
|
474
484
|
#define grpc_raw_byte_buffer_from_reader grpc_raw_byte_buffer_from_reader_import
|
475
|
-
typedef void(*gpr_log_type)(const char *file, int line, gpr_log_severity severity, const char *format, ...);
|
485
|
+
typedef void(*gpr_log_type)(const char *file, int line, gpr_log_severity severity, const char *format, ...) GPRC_PRINT_FORMAT_CHECK(4, 5);
|
476
486
|
extern gpr_log_type gpr_log_import;
|
477
487
|
#define gpr_log gpr_log_import
|
478
488
|
typedef void(*gpr_log_message_type)(const char *file, int line, gpr_log_severity severity, const char *message);
|
@@ -721,6 +731,12 @@ extern gpr_avl_remove_type gpr_avl_remove_import;
|
|
721
731
|
typedef void *(*gpr_avl_get_type)(gpr_avl avl, void *key);
|
722
732
|
extern gpr_avl_get_type gpr_avl_get_import;
|
723
733
|
#define gpr_avl_get gpr_avl_get_import
|
734
|
+
typedef int(*gpr_avl_maybe_get_type)(gpr_avl avl, void *key, void **value);
|
735
|
+
extern gpr_avl_maybe_get_type gpr_avl_maybe_get_import;
|
736
|
+
#define gpr_avl_maybe_get gpr_avl_maybe_get_import
|
737
|
+
typedef int(*gpr_avl_is_empty_type)(gpr_avl avl);
|
738
|
+
extern gpr_avl_is_empty_type gpr_avl_is_empty_import;
|
739
|
+
#define gpr_avl_is_empty gpr_avl_is_empty_import
|
724
740
|
typedef gpr_cmdline *(*gpr_cmdline_create_type)(const char *description);
|
725
741
|
extern gpr_cmdline_create_type gpr_cmdline_create_import;
|
726
742
|
#define gpr_cmdline_create gpr_cmdline_create_import
|
@@ -811,7 +827,7 @@ extern gpr_format_message_type gpr_format_message_import;
|
|
811
827
|
typedef char *(*gpr_strdup_type)(const char *src);
|
812
828
|
extern gpr_strdup_type gpr_strdup_import;
|
813
829
|
#define gpr_strdup gpr_strdup_import
|
814
|
-
typedef int(*gpr_asprintf_type)(char **strp, const char *format, ...);
|
830
|
+
typedef int(*gpr_asprintf_type)(char **strp, const char *format, ...) GPRC_PRINT_FORMAT_CHECK(2, 3);
|
815
831
|
extern gpr_asprintf_type gpr_asprintf_import;
|
816
832
|
#define gpr_asprintf gpr_asprintf_import
|
817
833
|
typedef const char *(*gpr_subprocess_binary_extension_type)();
|
@@ -856,6 +872,6 @@ extern gpr_thd_join_type gpr_thd_join_import;
|
|
856
872
|
|
857
873
|
void grpc_rb_load_imports(HMODULE library);
|
858
874
|
|
859
|
-
#endif /*
|
875
|
+
#endif /* GPR_WINDOWS */
|
860
876
|
|
861
877
|
#endif
|
@@ -60,6 +60,7 @@ typedef struct grpc_rb_server {
|
|
60
60
|
VALUE mark;
|
61
61
|
/* The actual server */
|
62
62
|
grpc_server *wrapped;
|
63
|
+
grpc_completion_queue *queue;
|
63
64
|
} grpc_rb_server;
|
64
65
|
|
65
66
|
/* Destroys server instances. */
|
@@ -145,6 +146,7 @@ static VALUE grpc_rb_server_init(VALUE self, VALUE cqueue, VALUE channel_args) {
|
|
145
146
|
}
|
146
147
|
grpc_server_register_completion_queue(srv, cq, NULL);
|
147
148
|
wrapper->wrapped = srv;
|
149
|
+
wrapper->queue = cq;
|
148
150
|
|
149
151
|
/* Add the cq as the server's mark object. This ensures the ruby cq can't be
|
150
152
|
GCed before the server */
|
@@ -232,7 +234,7 @@ static VALUE grpc_rb_server_request_call(VALUE self, VALUE cqueue,
|
|
232
234
|
err = grpc_server_request_call(
|
233
235
|
s->wrapped, &call, &st.details, &st.md_ary,
|
234
236
|
grpc_rb_get_wrapped_completion_queue(cqueue),
|
235
|
-
grpc_rb_get_wrapped_completion_queue(
|
237
|
+
grpc_rb_get_wrapped_completion_queue(s->mark),
|
236
238
|
ROBJECT(tag_new));
|
237
239
|
if (err != GRPC_CALL_OK) {
|
238
240
|
grpc_request_call_stack_cleanup(&st);
|
@@ -242,7 +244,7 @@ static VALUE grpc_rb_server_request_call(VALUE self, VALUE cqueue,
|
|
242
244
|
return Qnil;
|
243
245
|
}
|
244
246
|
|
245
|
-
ev = grpc_rb_completion_queue_pluck_event(
|
247
|
+
ev = grpc_rb_completion_queue_pluck_event(s->mark, tag_new, timeout);
|
246
248
|
if (ev.type == GRPC_QUEUE_TIMEOUT) {
|
247
249
|
grpc_request_call_stack_cleanup(&st);
|
248
250
|
return Qnil;
|
@@ -260,7 +262,7 @@ static VALUE grpc_rb_server_request_call(VALUE self, VALUE cqueue,
|
|
260
262
|
rb_str_new2(st.details.host),
|
261
263
|
rb_funcall(rb_cTime, id_at, 2, INT2NUM(deadline.tv_sec),
|
262
264
|
INT2NUM(deadline.tv_nsec)),
|
263
|
-
grpc_rb_md_ary_to_h(&st.md_ary), grpc_rb_wrap_call(call), NULL);
|
265
|
+
grpc_rb_md_ary_to_h(&st.md_ary), grpc_rb_wrap_call(call), cqueue, NULL);
|
264
266
|
grpc_request_call_stack_cleanup(&st);
|
265
267
|
return result;
|
266
268
|
}
|
data/src/ruby/lib/grpc.rb
CHANGED
@@ -33,7 +33,6 @@ require_relative 'grpc/errors'
|
|
33
33
|
require_relative 'grpc/grpc'
|
34
34
|
require_relative 'grpc/logconfig'
|
35
35
|
require_relative 'grpc/notifier'
|
36
|
-
require_relative 'grpc/signals'
|
37
36
|
require_relative 'grpc/version'
|
38
37
|
require_relative 'grpc/core/time_consts'
|
39
38
|
require_relative 'grpc/generic/active_call'
|
@@ -48,5 +47,3 @@ begin
|
|
48
47
|
ensure
|
49
48
|
file.close
|
50
49
|
end
|
51
|
-
|
52
|
-
GRPC::Signals.wait_for_signals
|
data/src/ruby/lib/grpc/errors.rb
CHANGED
@@ -40,11 +40,12 @@ module GRPC
|
|
40
40
|
|
41
41
|
# @param code [Numeric] the status code
|
42
42
|
# @param details [String] the details of the exception
|
43
|
-
|
43
|
+
# @param metadata [Hash] the error's metadata
|
44
|
+
def initialize(code, details = 'unknown cause', metadata = {})
|
44
45
|
super("#{code}:#{details}")
|
45
46
|
@code = code
|
46
47
|
@details = details
|
47
|
-
@metadata =
|
48
|
+
@metadata = metadata
|
48
49
|
end
|
49
50
|
|
50
51
|
# Converts the exception to a GRPC::Status for use in the networking
|
@@ -30,7 +30,6 @@
|
|
30
30
|
require 'forwardable'
|
31
31
|
require 'weakref'
|
32
32
|
require_relative 'bidi_call'
|
33
|
-
require_relative '../signals'
|
34
33
|
|
35
34
|
class Struct
|
36
35
|
# BatchResult is the struct returned by calls to call#start_batch.
|
@@ -45,7 +44,7 @@ class Struct
|
|
45
44
|
# raise BadStatus, propagating the metadata if present.
|
46
45
|
md = status.metadata
|
47
46
|
with_sym_keys = Hash[md.each_pair.collect { |x, y| [x.to_sym, y] }]
|
48
|
-
fail GRPC::BadStatus.new(status.code, status.details,
|
47
|
+
fail GRPC::BadStatus.new(status.code, status.details, with_sym_keys)
|
49
48
|
end
|
50
49
|
status
|
51
50
|
end
|
@@ -77,14 +76,15 @@ module GRPC
|
|
77
76
|
#
|
78
77
|
# @param call [Call] a call on which to start and invocation
|
79
78
|
# @param q [CompletionQueue] the completion queue
|
80
|
-
|
79
|
+
# @param metadata [Hash] the metadata
|
80
|
+
def self.client_invoke(call, q, metadata = {})
|
81
81
|
fail(TypeError, '!Core::Call') unless call.is_a? Core::Call
|
82
82
|
unless q.is_a? Core::CompletionQueue
|
83
83
|
fail(TypeError, '!Core::CompletionQueue')
|
84
84
|
end
|
85
85
|
metadata_tag = Object.new
|
86
86
|
call.run_batch(q, metadata_tag, INFINITE_FUTURE,
|
87
|
-
SEND_INITIAL_METADATA =>
|
87
|
+
SEND_INITIAL_METADATA => metadata)
|
88
88
|
metadata_tag
|
89
89
|
end
|
90
90
|
|
@@ -103,7 +103,7 @@ module GRPC
|
|
103
103
|
#
|
104
104
|
# @param call [Call] the call used by the ActiveCall
|
105
105
|
# @param q [CompletionQueue] the completion queue used to accept
|
106
|
-
# the call
|
106
|
+
# the call. This queue will be closed on call completion.
|
107
107
|
# @param marshal [Function] f(obj)->string that marshal requests
|
108
108
|
# @param unmarshal [Function] f(string)->obj that unmarshals responses
|
109
109
|
# @param deadline [Fixnum] the deadline for the call to complete
|
@@ -123,10 +123,6 @@ module GRPC
|
|
123
123
|
@unmarshal = unmarshal
|
124
124
|
@metadata_tag = metadata_tag
|
125
125
|
@op_notifier = nil
|
126
|
-
weak_self = WeakRef.new(self)
|
127
|
-
remove_handler = GRPC::Signals.register_handler(&weak_self
|
128
|
-
.method(:cancel))
|
129
|
-
ObjectSpace.define_finalizer(self, remove_handler)
|
130
126
|
end
|
131
127
|
|
132
128
|
# output_metadata are provides access to hash that can be used to
|
@@ -195,6 +191,8 @@ module GRPC
|
|
195
191
|
@call.status = batch_result.status
|
196
192
|
op_is_done
|
197
193
|
batch_result.check_status
|
194
|
+
@call.close
|
195
|
+
@cq.close
|
198
196
|
end
|
199
197
|
|
200
198
|
# remote_send sends a request to the remote endpoint.
|
@@ -216,13 +214,12 @@ module GRPC
|
|
216
214
|
# @param details [String] details
|
217
215
|
# @param assert_finished [true, false] when true(default), waits for
|
218
216
|
# FINISHED.
|
219
|
-
#
|
220
|
-
#
|
221
|
-
|
222
|
-
|
223
|
-
def send_status(code = OK, details = '', assert_finished = false, **kw)
|
217
|
+
# @param metadata [Hash] metadata to send to the server. If a value is a
|
218
|
+
# list, mulitple metadata for its key are sent
|
219
|
+
def send_status(code = OK, details = '', assert_finished = false,
|
220
|
+
metadata: {})
|
224
221
|
ops = {
|
225
|
-
SEND_STATUS_FROM_SERVER => Struct::Status.new(code, details,
|
222
|
+
SEND_STATUS_FROM_SERVER => Struct::Status.new(code, details, metadata)
|
226
223
|
}
|
227
224
|
ops[RECV_CLOSE_ON_SERVER] = nil if assert_finished
|
228
225
|
@call.run_batch(@cq, self, INFINITE_FUTURE, ops)
|
@@ -316,14 +313,12 @@ module GRPC
|
|
316
313
|
# request_response sends a request to a GRPC server, and returns the
|
317
314
|
# response.
|
318
315
|
#
|
319
|
-
# == Keyword Arguments ==
|
320
|
-
# any keyword arguments are treated as metadata to be sent to the server
|
321
|
-
# if a keyword value is a list, multiple metadata for it's key are sent
|
322
|
-
#
|
323
316
|
# @param req [Object] the request sent to the server
|
317
|
+
# @param metadata [Hash] metadata to be sent to the server. If a value is
|
318
|
+
# a list, multiple metadata for its key are sent
|
324
319
|
# @return [Object] the response received from the server
|
325
|
-
def request_response(req,
|
326
|
-
start_call(
|
320
|
+
def request_response(req, metadata: {})
|
321
|
+
start_call(metadata) unless @started
|
327
322
|
remote_send(req)
|
328
323
|
writes_done(false)
|
329
324
|
response = remote_read
|
@@ -342,14 +337,12 @@ module GRPC
|
|
342
337
|
# array of marshallable objects; in typical case it will be an Enumerable
|
343
338
|
# that allows dynamic construction of the marshallable objects.
|
344
339
|
#
|
345
|
-
# == Keyword Arguments ==
|
346
|
-
# any keyword arguments are treated as metadata to be sent to the server
|
347
|
-
# if a keyword value is a list, multiple metadata for it's key are sent
|
348
|
-
#
|
349
340
|
# @param requests [Object] an Enumerable of requests to send
|
341
|
+
# @param metadata [Hash] metadata to be sent to the server. If a value is
|
342
|
+
# a list, multiple metadata for its key are sent
|
350
343
|
# @return [Object] the response received from the server
|
351
|
-
def client_streamer(requests,
|
352
|
-
start_call(
|
344
|
+
def client_streamer(requests, metadata: {})
|
345
|
+
start_call(metadata) unless @started
|
353
346
|
requests.each { |r| remote_send(r) }
|
354
347
|
writes_done(false)
|
355
348
|
response = remote_read
|
@@ -370,15 +363,12 @@ module GRPC
|
|
370
363
|
# it is executed with each response as the argument and no result is
|
371
364
|
# returned.
|
372
365
|
#
|
373
|
-
# == Keyword Arguments ==
|
374
|
-
# any keyword arguments are treated as metadata to be sent to the server
|
375
|
-
# if a keyword value is a list, multiple metadata for it's key are sent
|
376
|
-
# any keyword arguments are treated as metadata to be sent to the server.
|
377
|
-
#
|
378
366
|
# @param req [Object] the request sent to the server
|
367
|
+
# @param metadata [Hash] metadata to be sent to the server. If a value is
|
368
|
+
# a list, multiple metadata for its key are sent
|
379
369
|
# @return [Enumerator|nil] a response Enumerator
|
380
|
-
def server_streamer(req,
|
381
|
-
start_call(
|
370
|
+
def server_streamer(req, metadata: {})
|
371
|
+
start_call(metadata) unless @started
|
382
372
|
remote_send(req)
|
383
373
|
writes_done(false)
|
384
374
|
replies = enum_for(:each_remote_read_then_finish)
|
@@ -412,14 +402,12 @@ module GRPC
|
|
412
402
|
# the_call#writes_done has been called, otherwise the block will loop
|
413
403
|
# forever.
|
414
404
|
#
|
415
|
-
# == Keyword Arguments ==
|
416
|
-
# any keyword arguments are treated as metadata to be sent to the server
|
417
|
-
# if a keyword value is a list, multiple metadata for it's key are sent
|
418
|
-
#
|
419
405
|
# @param requests [Object] an Enumerable of requests to send
|
406
|
+
# @param metadata [Hash] metadata to be sent to the server. If a value is
|
407
|
+
# a list, multiple metadata for its key are sent
|
420
408
|
# @return [Enumerator, nil] a response Enumerator
|
421
|
-
def bidi_streamer(requests,
|
422
|
-
start_call(
|
409
|
+
def bidi_streamer(requests, metadata: {}, &blk)
|
410
|
+
start_call(metadata) unless @started
|
423
411
|
bd = BidiCall.new(@call, @cq, @marshal, @unmarshal,
|
424
412
|
metadata_tag: @metadata_tag)
|
425
413
|
@metadata_tag = nil # run_on_client ensures metadata is read
|
@@ -458,9 +446,11 @@ module GRPC
|
|
458
446
|
private
|
459
447
|
|
460
448
|
# Starts the call if not already started
|
461
|
-
|
449
|
+
# @param metadata [Hash] metadata to be sent to the server. If a value is
|
450
|
+
# a list, multiple metadata for its key are sent
|
451
|
+
def start_call(metadata = {})
|
462
452
|
return if @started
|
463
|
-
@metadata_tag = ActiveCall.client_invoke(@call, @cq,
|
453
|
+
@metadata_tag = ActiveCall.client_invoke(@call, @cq, metadata)
|
464
454
|
@started = true
|
465
455
|
end
|
466
456
|
|
@@ -69,6 +69,10 @@ module GRPC
|
|
69
69
|
@readq = Queue.new
|
70
70
|
@unmarshal = unmarshal
|
71
71
|
@metadata_tag = metadata_tag
|
72
|
+
@reads_complete = false
|
73
|
+
@writes_complete = false
|
74
|
+
@complete = false
|
75
|
+
@done_mutex = Mutex.new
|
72
76
|
end
|
73
77
|
|
74
78
|
# Begins orchestration of the Bidi stream for a client sending requests.
|
@@ -115,6 +119,16 @@ module GRPC
|
|
115
119
|
@op_notifier.notify(self)
|
116
120
|
end
|
117
121
|
|
122
|
+
# signals that a bidi operation is complete (read + write)
|
123
|
+
def finished
|
124
|
+
@done_mutex.synchronize do
|
125
|
+
return unless @reads_complete && @writes_complete && !@complete
|
126
|
+
@call.close
|
127
|
+
@cq.close
|
128
|
+
@complete = true
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
118
132
|
# performs a read using @call.run_batch, ensures metadata is set up
|
119
133
|
def read_using_run_batch
|
120
134
|
ops = { RECV_MESSAGE => nil }
|
@@ -163,12 +177,16 @@ module GRPC
|
|
163
177
|
SEND_CLOSE_FROM_CLIENT => nil)
|
164
178
|
GRPC.logger.debug('bidi-write-loop: done')
|
165
179
|
notify_done
|
180
|
+
@writes_complete = true
|
181
|
+
finished
|
166
182
|
end
|
167
183
|
GRPC.logger.debug('bidi-write-loop: finished')
|
168
184
|
rescue StandardError => e
|
169
185
|
GRPC.logger.warn('bidi-write-loop: failed')
|
170
186
|
GRPC.logger.warn(e)
|
171
187
|
notify_done
|
188
|
+
@writes_complete = true
|
189
|
+
finished
|
172
190
|
raise e
|
173
191
|
end
|
174
192
|
|
@@ -212,6 +230,8 @@ module GRPC
|
|
212
230
|
@readq.push(e) # let each_queued_msg terminate with this error
|
213
231
|
end
|
214
232
|
GRPC.logger.debug('bidi-read-loop: finished')
|
233
|
+
@reads_complete = true
|
234
|
+
finished
|
215
235
|
end
|
216
236
|
end
|
217
237
|
end
|