awesome-grpc-that-works 0.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Makefile +29456 -0
- data/Rakefile +63 -0
- data/etc/roots.pem +5114 -0
- data/include/grpc/byte_buffer.h +120 -0
- data/include/grpc/byte_buffer_reader.h +58 -0
- data/include/grpc/census.h +488 -0
- data/include/grpc/compression.h +106 -0
- data/include/grpc/grpc.h +732 -0
- data/include/grpc/grpc_security.h +374 -0
- data/include/grpc/grpc_zookeeper.h +59 -0
- data/include/grpc/status.h +163 -0
- data/include/grpc/support/alloc.h +72 -0
- data/include/grpc/support/atm.h +92 -0
- data/include/grpc/support/atm_gcc_atomic.h +72 -0
- data/include/grpc/support/atm_gcc_sync.h +87 -0
- data/include/grpc/support/atm_win32.h +125 -0
- data/include/grpc/support/avl.h +91 -0
- data/include/grpc/support/cmdline.h +101 -0
- data/include/grpc/support/cpu.h +57 -0
- data/include/grpc/support/histogram.h +76 -0
- data/include/grpc/support/host_port.h +64 -0
- data/include/grpc/support/log.h +108 -0
- data/include/grpc/support/log_win32.h +51 -0
- data/include/grpc/support/port_platform.h +356 -0
- data/include/grpc/support/slice.h +182 -0
- data/include/grpc/support/slice_buffer.h +102 -0
- data/include/grpc/support/string_util.h +61 -0
- data/include/grpc/support/subprocess.h +57 -0
- data/include/grpc/support/sync.h +315 -0
- data/include/grpc/support/sync_generic.h +55 -0
- data/include/grpc/support/sync_posix.h +47 -0
- data/include/grpc/support/sync_win32.h +49 -0
- data/include/grpc/support/thd.h +91 -0
- data/include/grpc/support/time.h +128 -0
- data/include/grpc/support/tls.h +77 -0
- data/include/grpc/support/tls_gcc.h +56 -0
- data/include/grpc/support/tls_msvc.h +56 -0
- data/include/grpc/support/tls_pthread.h +60 -0
- data/include/grpc/support/useful.h +75 -0
- data/src/core/census/aggregation.h +66 -0
- data/src/core/census/context.c +46 -0
- data/src/core/census/context.h +47 -0
- data/src/core/census/grpc_context.c +53 -0
- data/src/core/census/grpc_filter.c +184 -0
- data/src/core/census/grpc_filter.h +44 -0
- data/src/core/census/initialize.c +57 -0
- data/src/core/census/operation.c +63 -0
- data/src/core/census/rpc_metric_id.h +51 -0
- data/src/core/census/tracing.c +45 -0
- data/src/core/channel/channel_args.c +209 -0
- data/src/core/channel/channel_args.h +88 -0
- data/src/core/channel/channel_stack.c +262 -0
- data/src/core/channel/channel_stack.h +260 -0
- data/src/core/channel/client_channel.c +524 -0
- data/src/core/channel/client_channel.h +63 -0
- data/src/core/channel/client_uchannel.c +243 -0
- data/src/core/channel/client_uchannel.h +60 -0
- data/src/core/channel/compress_filter.c +297 -0
- data/src/core/channel/compress_filter.h +65 -0
- data/src/core/channel/connected_channel.c +167 -0
- data/src/core/channel/connected_channel.h +51 -0
- data/src/core/channel/context.h +49 -0
- data/src/core/channel/http_client_filter.c +248 -0
- data/src/core/channel/http_client_filter.h +44 -0
- data/src/core/channel/http_server_filter.c +233 -0
- data/src/core/channel/http_server_filter.h +42 -0
- data/src/core/channel/subchannel_call_holder.c +259 -0
- data/src/core/channel/subchannel_call_holder.h +98 -0
- data/src/core/client_config/client_config.c +72 -0
- data/src/core/client_config/client_config.h +53 -0
- data/src/core/client_config/connector.c +54 -0
- data/src/core/client_config/connector.h +95 -0
- data/src/core/client_config/default_initial_connect_string.c +39 -0
- data/src/core/client_config/initial_connect_string.c +53 -0
- data/src/core/client_config/initial_connect_string.h +50 -0
- data/src/core/client_config/lb_policies/pick_first.c +398 -0
- data/src/core/client_config/lb_policies/pick_first.h +43 -0
- data/src/core/client_config/lb_policies/round_robin.c +537 -0
- data/src/core/client_config/lb_policies/round_robin.h +46 -0
- data/src/core/client_config/lb_policy.c +134 -0
- data/src/core/client_config/lb_policy.h +143 -0
- data/src/core/client_config/lb_policy_factory.c +48 -0
- data/src/core/client_config/lb_policy_factory.h +73 -0
- data/src/core/client_config/lb_policy_registry.c +88 -0
- data/src/core/client_config/lb_policy_registry.h +54 -0
- data/src/core/client_config/resolver.c +82 -0
- data/src/core/client_config/resolver.h +94 -0
- data/src/core/client_config/resolver_factory.c +55 -0
- data/src/core/client_config/resolver_factory.h +82 -0
- data/src/core/client_config/resolver_registry.c +137 -0
- data/src/core/client_config/resolver_registry.h +65 -0
- data/src/core/client_config/resolvers/dns_resolver.c +257 -0
- data/src/core/client_config/resolvers/dns_resolver.h +42 -0
- data/src/core/client_config/resolvers/sockaddr_resolver.c +391 -0
- data/src/core/client_config/resolvers/sockaddr_resolver.h +50 -0
- data/src/core/client_config/subchannel.c +697 -0
- data/src/core/client_config/subchannel.h +165 -0
- data/src/core/client_config/subchannel_factory.c +49 -0
- data/src/core/client_config/subchannel_factory.h +66 -0
- data/src/core/client_config/uri_parser.c +242 -0
- data/src/core/client_config/uri_parser.h +51 -0
- data/src/core/compression/algorithm.c +166 -0
- data/src/core/compression/algorithm_metadata.h +53 -0
- data/src/core/compression/message_compress.c +198 -0
- data/src/core/compression/message_compress.h +52 -0
- data/src/core/debug/trace.c +136 -0
- data/src/core/debug/trace.h +43 -0
- data/src/core/httpcli/format_request.c +120 -0
- data/src/core/httpcli/format_request.h +45 -0
- data/src/core/httpcli/httpcli.c +286 -0
- data/src/core/httpcli/httpcli.h +162 -0
- data/src/core/httpcli/httpcli_security_connector.c +189 -0
- data/src/core/httpcli/parser.c +211 -0
- data/src/core/httpcli/parser.h +64 -0
- data/src/core/iomgr/closure.c +98 -0
- data/src/core/iomgr/closure.h +97 -0
- data/src/core/iomgr/endpoint.c +67 -0
- data/src/core/iomgr/endpoint.h +102 -0
- data/src/core/iomgr/endpoint_pair.h +47 -0
- data/src/core/iomgr/endpoint_pair_posix.c +82 -0
- data/src/core/iomgr/endpoint_pair_windows.c +97 -0
- data/src/core/iomgr/exec_ctx.c +72 -0
- data/src/core/iomgr/exec_ctx.h +78 -0
- data/src/core/iomgr/executor.c +143 -0
- data/src/core/iomgr/executor.h +53 -0
- data/src/core/iomgr/fd_posix.c +438 -0
- data/src/core/iomgr/fd_posix.h +189 -0
- data/src/core/iomgr/iocp_windows.c +206 -0
- data/src/core/iomgr/iocp_windows.h +56 -0
- data/src/core/iomgr/iomgr.c +156 -0
- data/src/core/iomgr/iomgr.h +43 -0
- data/src/core/iomgr/iomgr_internal.h +58 -0
- data/src/core/iomgr/iomgr_posix.c +52 -0
- data/src/core/iomgr/iomgr_posix.h +39 -0
- data/src/core/iomgr/iomgr_windows.c +73 -0
- data/src/core/iomgr/pollset.h +95 -0
- data/src/core/iomgr/pollset_multipoller_with_epoll.c +258 -0
- data/src/core/iomgr/pollset_multipoller_with_poll_posix.c +227 -0
- data/src/core/iomgr/pollset_posix.c +638 -0
- data/src/core/iomgr/pollset_posix.h +147 -0
- data/src/core/iomgr/pollset_set.h +67 -0
- data/src/core/iomgr/pollset_set_posix.c +182 -0
- data/src/core/iomgr/pollset_set_posix.h +61 -0
- data/src/core/iomgr/pollset_set_windows.c +60 -0
- data/src/core/iomgr/pollset_set_windows.h +39 -0
- data/src/core/iomgr/pollset_windows.c +248 -0
- data/src/core/iomgr/pollset_windows.h +79 -0
- data/src/core/iomgr/resolve_address.h +72 -0
- data/src/core/iomgr/resolve_address_posix.c +183 -0
- data/src/core/iomgr/resolve_address_windows.c +166 -0
- data/src/core/iomgr/sockaddr.h +47 -0
- data/src/core/iomgr/sockaddr_posix.h +44 -0
- data/src/core/iomgr/sockaddr_utils.c +234 -0
- data/src/core/iomgr/sockaddr_utils.h +89 -0
- data/src/core/iomgr/sockaddr_win32.h +46 -0
- data/src/core/iomgr/socket_utils_common_posix.c +208 -0
- data/src/core/iomgr/socket_utils_linux.c +51 -0
- data/src/core/iomgr/socket_utils_posix.c +70 -0
- data/src/core/iomgr/socket_utils_posix.h +113 -0
- data/src/core/iomgr/socket_windows.c +98 -0
- data/src/core/iomgr/socket_windows.h +111 -0
- data/src/core/iomgr/tcp_client.h +53 -0
- data/src/core/iomgr/tcp_client_posix.c +304 -0
- data/src/core/iomgr/tcp_client_windows.c +221 -0
- data/src/core/iomgr/tcp_posix.c +485 -0
- data/src/core/iomgr/tcp_posix.h +65 -0
- data/src/core/iomgr/tcp_server.h +83 -0
- data/src/core/iomgr/tcp_server_posix.c +562 -0
- data/src/core/iomgr/tcp_server_windows.c +509 -0
- data/src/core/iomgr/tcp_windows.c +406 -0
- data/src/core/iomgr/tcp_windows.h +57 -0
- data/src/core/iomgr/time_averaged_stats.c +77 -0
- data/src/core/iomgr/time_averaged_stats.h +88 -0
- data/src/core/iomgr/timer.c +345 -0
- data/src/core/iomgr/timer.h +89 -0
- data/src/core/iomgr/timer_heap.c +148 -0
- data/src/core/iomgr/timer_heap.h +57 -0
- data/src/core/iomgr/timer_internal.h +61 -0
- data/src/core/iomgr/udp_server.c +439 -0
- data/src/core/iomgr/udp_server.h +83 -0
- data/src/core/iomgr/wakeup_fd_eventfd.c +85 -0
- data/src/core/iomgr/wakeup_fd_nospecial.c +51 -0
- data/src/core/iomgr/wakeup_fd_pipe.c +97 -0
- data/src/core/iomgr/wakeup_fd_pipe.h +41 -0
- data/src/core/iomgr/wakeup_fd_posix.c +72 -0
- data/src/core/iomgr/wakeup_fd_posix.h +101 -0
- data/src/core/iomgr/workqueue.h +85 -0
- data/src/core/iomgr/workqueue_posix.c +143 -0
- data/src/core/iomgr/workqueue_posix.h +51 -0
- data/src/core/iomgr/workqueue_windows.c +40 -0
- data/src/core/iomgr/workqueue_windows.h +37 -0
- data/src/core/json/json.c +64 -0
- data/src/core/json/json.h +88 -0
- data/src/core/json/json_common.h +49 -0
- data/src/core/json/json_reader.c +660 -0
- data/src/core/json/json_reader.h +160 -0
- data/src/core/json/json_string.c +379 -0
- data/src/core/json/json_writer.c +260 -0
- data/src/core/json/json_writer.h +97 -0
- data/src/core/profiling/basic_timers.c +274 -0
- data/src/core/profiling/stap_timers.c +65 -0
- data/src/core/profiling/timers.h +119 -0
- data/src/core/security/auth_filters.h +42 -0
- data/src/core/security/base64.c +233 -0
- data/src/core/security/base64.h +52 -0
- data/src/core/security/client_auth_filter.c +337 -0
- data/src/core/security/credentials.c +1273 -0
- data/src/core/security/credentials.h +376 -0
- data/src/core/security/credentials_metadata.c +101 -0
- data/src/core/security/credentials_posix.c +61 -0
- data/src/core/security/credentials_win32.c +61 -0
- data/src/core/security/google_default_credentials.c +260 -0
- data/src/core/security/handshake.c +327 -0
- data/src/core/security/handshake.h +50 -0
- data/src/core/security/json_token.c +405 -0
- data/src/core/security/json_token.h +118 -0
- data/src/core/security/jwt_verifier.c +842 -0
- data/src/core/security/jwt_verifier.h +136 -0
- data/src/core/security/secure_endpoint.c +383 -0
- data/src/core/security/secure_endpoint.h +49 -0
- data/src/core/security/security_connector.c +756 -0
- data/src/core/security/security_connector.h +246 -0
- data/src/core/security/security_context.c +342 -0
- data/src/core/security/security_context.h +114 -0
- data/src/core/security/server_auth_filter.c +264 -0
- data/src/core/security/server_secure_chttp2.c +268 -0
- data/src/core/statistics/census_interface.h +76 -0
- data/src/core/statistics/census_rpc_stats.h +101 -0
- data/src/core/support/alloc.c +90 -0
- data/src/core/support/avl.c +288 -0
- data/src/core/support/block_annotate.h +48 -0
- data/src/core/support/cmdline.c +347 -0
- data/src/core/support/cpu_iphone.c +49 -0
- data/src/core/support/cpu_linux.c +78 -0
- data/src/core/support/cpu_posix.c +77 -0
- data/src/core/support/cpu_windows.c +47 -0
- data/src/core/support/env.h +60 -0
- data/src/core/support/env_linux.c +62 -0
- data/src/core/support/env_posix.c +57 -0
- data/src/core/support/env_win32.c +65 -0
- data/src/core/support/file.c +91 -0
- data/src/core/support/file.h +63 -0
- data/src/core/support/file_posix.c +85 -0
- data/src/core/support/file_win32.c +84 -0
- data/src/core/support/histogram.c +244 -0
- data/src/core/support/host_port.c +110 -0
- data/src/core/support/log.c +66 -0
- data/src/core/support/log_android.c +87 -0
- data/src/core/support/log_linux.c +105 -0
- data/src/core/support/log_posix.c +102 -0
- data/src/core/support/log_win32.c +125 -0
- data/src/core/support/murmur_hash.c +96 -0
- data/src/core/support/murmur_hash.h +44 -0
- data/src/core/support/slice.c +343 -0
- data/src/core/support/slice_buffer.c +282 -0
- data/src/core/support/stack_lockfree.c +175 -0
- data/src/core/support/stack_lockfree.h +53 -0
- data/src/core/support/string.c +296 -0
- data/src/core/support/string.h +121 -0
- data/src/core/support/string_posix.c +86 -0
- data/src/core/support/string_win32.c +109 -0
- data/src/core/support/string_win32.h +47 -0
- data/src/core/support/subprocess_posix.c +112 -0
- data/src/core/support/sync.c +122 -0
- data/src/core/support/sync_posix.c +104 -0
- data/src/core/support/sync_win32.c +128 -0
- data/src/core/support/thd.c +64 -0
- data/src/core/support/thd_internal.h +39 -0
- data/src/core/support/thd_posix.c +94 -0
- data/src/core/support/thd_win32.c +117 -0
- data/src/core/support/time.c +304 -0
- data/src/core/support/time_posix.c +161 -0
- data/src/core/support/time_precise.c +89 -0
- data/src/core/support/time_precise.h +42 -0
- data/src/core/support/time_win32.c +101 -0
- data/src/core/support/tls_pthread.c +45 -0
- data/src/core/surface/api_trace.c +36 -0
- data/src/core/surface/api_trace.h +65 -0
- data/src/core/surface/byte_buffer.c +97 -0
- data/src/core/surface/byte_buffer_reader.c +123 -0
- data/src/core/surface/call.c +1424 -0
- data/src/core/surface/call.h +109 -0
- data/src/core/surface/call_details.c +50 -0
- data/src/core/surface/call_log_batch.c +118 -0
- data/src/core/surface/call_test_only.h +64 -0
- data/src/core/surface/channel.c +327 -0
- data/src/core/surface/channel.h +74 -0
- data/src/core/surface/channel_connectivity.c +220 -0
- data/src/core/surface/channel_create.c +235 -0
- data/src/core/surface/channel_ping.c +79 -0
- data/src/core/surface/completion_queue.c +481 -0
- data/src/core/surface/completion_queue.h +91 -0
- data/src/core/surface/event_string.c +81 -0
- data/src/core/surface/event_string.h +42 -0
- data/src/core/surface/init.c +168 -0
- data/src/core/surface/init.h +40 -0
- data/src/core/surface/init_secure.c +42 -0
- data/src/core/surface/lame_client.c +149 -0
- data/src/core/surface/metadata_array.c +49 -0
- data/src/core/surface/secure_channel_create.c +336 -0
- data/src/core/surface/server.c +1343 -0
- data/src/core/surface/server.h +67 -0
- data/src/core/surface/server_chttp2.c +149 -0
- data/src/core/surface/server_create.c +51 -0
- data/src/core/surface/surface_trace.h +48 -0
- data/src/core/surface/validate_metadata.c +73 -0
- data/src/core/surface/version.c +39 -0
- data/src/core/transport/byte_stream.c +76 -0
- data/src/core/transport/byte_stream.h +88 -0
- data/src/core/transport/chttp2/alpn.c +56 -0
- data/src/core/transport/chttp2/alpn.h +49 -0
- data/src/core/transport/chttp2/bin_encoder.c +285 -0
- data/src/core/transport/chttp2/bin_encoder.h +54 -0
- data/src/core/transport/chttp2/frame.h +69 -0
- data/src/core/transport/chttp2/frame_data.c +245 -0
- data/src/core/transport/chttp2/frame_data.h +101 -0
- data/src/core/transport/chttp2/frame_goaway.c +193 -0
- data/src/core/transport/chttp2/frame_goaway.h +77 -0
- data/src/core/transport/chttp2/frame_ping.c +97 -0
- data/src/core/transport/chttp2/frame_ping.h +56 -0
- data/src/core/transport/chttp2/frame_rst_stream.c +100 -0
- data/src/core/transport/chttp2/frame_rst_stream.h +55 -0
- data/src/core/transport/chttp2/frame_settings.c +259 -0
- data/src/core/transport/chttp2/frame_settings.h +103 -0
- data/src/core/transport/chttp2/frame_window_update.c +114 -0
- data/src/core/transport/chttp2/frame_window_update.h +58 -0
- data/src/core/transport/chttp2/hpack_encoder.c +572 -0
- data/src/core/transport/chttp2/hpack_encoder.h +95 -0
- data/src/core/transport/chttp2/hpack_parser.c +1449 -0
- data/src/core/transport/chttp2/hpack_parser.h +116 -0
- data/src/core/transport/chttp2/hpack_table.c +361 -0
- data/src/core/transport/chttp2/hpack_table.h +108 -0
- data/src/core/transport/chttp2/http2_errors.h +56 -0
- data/src/core/transport/chttp2/huffsyms.c +297 -0
- data/src/core/transport/chttp2/huffsyms.h +48 -0
- data/src/core/transport/chttp2/incoming_metadata.c +96 -0
- data/src/core/transport/chttp2/incoming_metadata.h +60 -0
- data/src/core/transport/chttp2/internal.h +757 -0
- data/src/core/transport/chttp2/parsing.c +866 -0
- data/src/core/transport/chttp2/status_conversion.c +109 -0
- data/src/core/transport/chttp2/status_conversion.h +50 -0
- data/src/core/transport/chttp2/stream_lists.c +401 -0
- data/src/core/transport/chttp2/stream_map.c +198 -0
- data/src/core/transport/chttp2/stream_map.h +85 -0
- data/src/core/transport/chttp2/timeout_encoding.c +185 -0
- data/src/core/transport/chttp2/timeout_encoding.h +47 -0
- data/src/core/transport/chttp2/varint.c +66 -0
- data/src/core/transport/chttp2/varint.h +76 -0
- data/src/core/transport/chttp2/writing.c +356 -0
- data/src/core/transport/chttp2_transport.c +1692 -0
- data/src/core/transport/chttp2_transport.h +51 -0
- data/src/core/transport/connectivity_state.c +164 -0
- data/src/core/transport/connectivity_state.h +85 -0
- data/src/core/transport/metadata.c +690 -0
- data/src/core/transport/metadata.h +156 -0
- data/src/core/transport/metadata_batch.c +194 -0
- data/src/core/transport/metadata_batch.h +125 -0
- data/src/core/transport/static_metadata.c +90 -0
- data/src/core/transport/static_metadata.h +408 -0
- data/src/core/transport/transport.c +183 -0
- data/src/core/transport/transport.h +222 -0
- data/src/core/transport/transport_impl.h +78 -0
- data/src/core/transport/transport_op_string.c +140 -0
- data/src/core/tsi/fake_transport_security.c +525 -0
- data/src/core/tsi/fake_transport_security.h +61 -0
- data/src/core/tsi/ssl_transport_security.c +1467 -0
- data/src/core/tsi/ssl_transport_security.h +173 -0
- data/src/core/tsi/transport_security.c +284 -0
- data/src/core/tsi/transport_security.h +111 -0
- data/src/core/tsi/transport_security_interface.h +344 -0
- data/src/ruby/bin/apis/google/protobuf/empty.rb +44 -0
- data/src/ruby/bin/apis/pubsub_demo.rb +256 -0
- data/src/ruby/bin/apis/tech/pubsub/proto/pubsub.rb +174 -0
- data/src/ruby/bin/apis/tech/pubsub/proto/pubsub_services.rb +103 -0
- data/src/ruby/bin/grpc_ruby_interop_client +33 -0
- data/src/ruby/bin/grpc_ruby_interop_server +33 -0
- data/src/ruby/bin/interop/interop_client.rb +51 -0
- data/src/ruby/bin/interop/interop_server.rb +50 -0
- data/src/ruby/bin/math.rb +32 -0
- data/src/ruby/bin/math_client.rb +147 -0
- data/src/ruby/bin/math_server.rb +206 -0
- data/src/ruby/bin/math_services.rb +27 -0
- data/src/ruby/bin/noproto_client.rb +108 -0
- data/src/ruby/bin/noproto_server.rb +112 -0
- data/src/ruby/ext/grpc/extconf.rb +92 -0
- data/src/ruby/ext/grpc/rb_byte_buffer.c +75 -0
- data/src/ruby/ext/grpc/rb_byte_buffer.h +47 -0
- data/src/ruby/ext/grpc/rb_call.c +915 -0
- data/src/ruby/ext/grpc/rb_call.h +66 -0
- data/src/ruby/ext/grpc/rb_call_credentials.c +315 -0
- data/src/ruby/ext/grpc/rb_call_credentials.h +46 -0
- data/src/ruby/ext/grpc/rb_channel.c +430 -0
- data/src/ruby/ext/grpc/rb_channel.h +47 -0
- data/src/ruby/ext/grpc/rb_channel_args.c +167 -0
- data/src/ruby/ext/grpc/rb_channel_args.h +53 -0
- data/src/ruby/ext/grpc/rb_channel_credentials.c +266 -0
- data/src/ruby/ext/grpc/rb_channel_credentials.h +47 -0
- data/src/ruby/ext/grpc/rb_completion_queue.c +181 -0
- data/src/ruby/ext/grpc/rb_completion_queue.h +55 -0
- data/src/ruby/ext/grpc/rb_event_thread.c +153 -0
- data/src/ruby/ext/grpc/rb_event_thread.h +37 -0
- data/src/ruby/ext/grpc/rb_grpc.c +328 -0
- data/src/ruby/ext/grpc/rb_grpc.h +85 -0
- data/src/ruby/ext/grpc/rb_server.c +398 -0
- data/src/ruby/ext/grpc/rb_server.h +47 -0
- data/src/ruby/ext/grpc/rb_server_credentials.c +282 -0
- data/src/ruby/ext/grpc/rb_server_credentials.h +47 -0
- data/src/ruby/lib/grpc/core/time_consts.rb +71 -0
- data/src/ruby/lib/grpc/errors.rb +62 -0
- data/src/ruby/lib/grpc/generic/active_call.rb +488 -0
- data/src/ruby/lib/grpc/generic/bidi_call.rb +218 -0
- data/src/ruby/lib/grpc/generic/client_stub.rb +471 -0
- data/src/ruby/lib/grpc/generic/rpc_desc.rb +147 -0
- data/src/ruby/lib/grpc/generic/rpc_server.rb +504 -0
- data/src/ruby/lib/grpc/generic/service.rb +234 -0
- data/src/ruby/lib/grpc/logconfig.rb +59 -0
- data/src/ruby/lib/grpc/notifier.rb +60 -0
- data/src/ruby/lib/grpc/version.rb +33 -0
- data/src/ruby/lib/grpc.rb +44 -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/v1alpha/health.rb +29 -0
- data/src/ruby/pb/grpc/health/v1alpha/health_services.rb +28 -0
- data/src/ruby/pb/test/client.rb +469 -0
- data/src/ruby/pb/test/proto/empty.rb +15 -0
- data/src/ruby/pb/test/proto/messages.rb +80 -0
- data/src/ruby/pb/test/proto/test.rb +14 -0
- data/src/ruby/pb/test/proto/test_services.rb +64 -0
- data/src/ruby/pb/test/server.rb +253 -0
- data/src/ruby/spec/call_credentials_spec.rb +57 -0
- data/src/ruby/spec/call_spec.rb +163 -0
- data/src/ruby/spec/channel_credentials_spec.rb +97 -0
- data/src/ruby/spec/channel_spec.rb +177 -0
- data/src/ruby/spec/client_server_spec.rb +475 -0
- data/src/ruby/spec/completion_queue_spec.rb +42 -0
- data/src/ruby/spec/generic/active_call_spec.rb +373 -0
- data/src/ruby/spec/generic/client_stub_spec.rb +476 -0
- data/src/ruby/spec/generic/rpc_desc_spec.rb +331 -0
- data/src/ruby/spec/generic/rpc_server_pool_spec.rb +138 -0
- data/src/ruby/spec/generic/rpc_server_spec.rb +576 -0
- data/src/ruby/spec/generic/service_spec.rb +345 -0
- data/src/ruby/spec/pb/health/checker_spec.rb +232 -0
- data/src/ruby/spec/server_credentials_spec.rb +94 -0
- data/src/ruby/spec/server_spec.rb +209 -0
- data/src/ruby/spec/spec_helper.rb +69 -0
- data/src/ruby/spec/testdata/README +1 -0
- data/src/ruby/spec/testdata/ca.pem +15 -0
- data/src/ruby/spec/testdata/server1.key +16 -0
- data/src/ruby/spec/testdata/server1.pem +16 -0
- data/src/ruby/spec/time_consts_spec.rb +89 -0
- metadata +665 -0
data/include/grpc/grpc.h
ADDED
@@ -0,0 +1,732 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2015-2016, Google Inc.
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
7
|
+
* modification, are permitted provided that the following conditions are
|
8
|
+
* met:
|
9
|
+
*
|
10
|
+
* * Redistributions of source code must retain the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer.
|
12
|
+
* * Redistributions in binary form must reproduce the above
|
13
|
+
* copyright notice, this list of conditions and the following disclaimer
|
14
|
+
* in the documentation and/or other materials provided with the
|
15
|
+
* distribution.
|
16
|
+
* * Neither the name of Google Inc. nor the names of its
|
17
|
+
* contributors may be used to endorse or promote products derived from
|
18
|
+
* this software without specific prior written permission.
|
19
|
+
*
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
21
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
22
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
23
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
24
|
+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
25
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
26
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
27
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
28
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
29
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
30
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
*
|
32
|
+
*/
|
33
|
+
|
34
|
+
#ifndef GRPC_GRPC_H
|
35
|
+
#define GRPC_GRPC_H
|
36
|
+
|
37
|
+
#include <grpc/status.h>
|
38
|
+
|
39
|
+
#include <stddef.h>
|
40
|
+
#include <grpc/byte_buffer.h>
|
41
|
+
#include <grpc/support/slice.h>
|
42
|
+
#include <grpc/support/time.h>
|
43
|
+
|
44
|
+
#ifdef __cplusplus
|
45
|
+
extern "C" {
|
46
|
+
#endif
|
47
|
+
|
48
|
+
/*! \mainpage GRPC Core
|
49
|
+
*
|
50
|
+
* The GRPC Core library is a low-level library designed to be wrapped by higher
|
51
|
+
* level libraries. The top-level API is provided in grpc.h. Security related
|
52
|
+
* functionality lives in grpc_security.h.
|
53
|
+
*/
|
54
|
+
|
55
|
+
/** Completion Queues enable notification of the completion of asynchronous
|
56
|
+
actions. */
|
57
|
+
typedef struct grpc_completion_queue grpc_completion_queue;
|
58
|
+
|
59
|
+
/** An alarm associated with a completion queue. */
|
60
|
+
typedef struct grpc_alarm grpc_alarm;
|
61
|
+
|
62
|
+
/** The Channel interface allows creation of Call objects. */
|
63
|
+
typedef struct grpc_channel grpc_channel;
|
64
|
+
|
65
|
+
/** A server listens to some port and responds to request calls */
|
66
|
+
typedef struct grpc_server grpc_server;
|
67
|
+
|
68
|
+
/** A Call represents an RPC. When created, it is in a configuration state
|
69
|
+
allowing properties to be set until it is invoked. After invoke, the Call
|
70
|
+
can have messages written to it and read from it. */
|
71
|
+
typedef struct grpc_call grpc_call;
|
72
|
+
|
73
|
+
/** Type specifier for grpc_arg */
|
74
|
+
typedef enum {
|
75
|
+
GRPC_ARG_STRING,
|
76
|
+
GRPC_ARG_INTEGER,
|
77
|
+
GRPC_ARG_POINTER
|
78
|
+
} grpc_arg_type;
|
79
|
+
|
80
|
+
/** A single argument... each argument has a key and a value
|
81
|
+
|
82
|
+
A note on naming keys:
|
83
|
+
Keys are namespaced into groups, usually grouped by library, and are
|
84
|
+
keys for module XYZ are named XYZ.key1, XYZ.key2, etc. Module names must
|
85
|
+
be restricted to the regex [A-Za-z][_A-Za-z0-9]{,15}.
|
86
|
+
Key names must be restricted to the regex [A-Za-z][_A-Za-z0-9]{,47}.
|
87
|
+
|
88
|
+
GRPC core library keys are prefixed by grpc.
|
89
|
+
|
90
|
+
Library authors are strongly encouraged to \#define symbolic constants for
|
91
|
+
their keys so that it's possible to change them in the future. */
|
92
|
+
typedef struct {
|
93
|
+
grpc_arg_type type;
|
94
|
+
char *key;
|
95
|
+
union {
|
96
|
+
char *string;
|
97
|
+
int integer;
|
98
|
+
struct {
|
99
|
+
void *p;
|
100
|
+
void *(*copy)(void *p);
|
101
|
+
void (*destroy)(void *p);
|
102
|
+
} pointer;
|
103
|
+
} value;
|
104
|
+
} grpc_arg;
|
105
|
+
|
106
|
+
/** An array of arguments that can be passed around.
|
107
|
+
|
108
|
+
Used to set optional channel-level configuration.
|
109
|
+
These configuration options are modelled as key-value pairs as defined
|
110
|
+
by grpc_arg; keys are strings to allow easy backwards-compatible extension
|
111
|
+
by arbitrary parties.
|
112
|
+
All evaluation is performed at channel creation time (i.e. the values in
|
113
|
+
this structure need only live through the creation invocation). */
|
114
|
+
typedef struct {
|
115
|
+
size_t num_args;
|
116
|
+
grpc_arg *args;
|
117
|
+
} grpc_channel_args;
|
118
|
+
|
119
|
+
/* Channel argument keys: */
|
120
|
+
/** Enable census for tracing and stats collection */
|
121
|
+
#define GRPC_ARG_ENABLE_CENSUS "grpc.census"
|
122
|
+
/** Maximum number of concurrent incoming streams to allow on a http2
|
123
|
+
connection */
|
124
|
+
#define GRPC_ARG_MAX_CONCURRENT_STREAMS "grpc.max_concurrent_streams"
|
125
|
+
/** Maximum message length that the channel can receive */
|
126
|
+
#define GRPC_ARG_MAX_MESSAGE_LENGTH "grpc.max_message_length"
|
127
|
+
/** Initial sequence number for http2 transports */
|
128
|
+
#define GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER \
|
129
|
+
"grpc.http2.initial_sequence_number"
|
130
|
+
/** Amount to read ahead on individual streams. Defaults to 64kb, larger
|
131
|
+
values can help throughput on high-latency connections.
|
132
|
+
NOTE: at some point we'd like to auto-tune this, and this parameter
|
133
|
+
will become a no-op. */
|
134
|
+
#define GRPC_ARG_HTTP2_STREAM_LOOKAHEAD_BYTES "grpc.http2.lookahead_bytes"
|
135
|
+
/** How much memory to use for hpack decoding */
|
136
|
+
#define GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_DECODER \
|
137
|
+
"grpc.http2.hpack_table_size.decoder"
|
138
|
+
/** How much memory to use for hpack encoding */
|
139
|
+
#define GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER \
|
140
|
+
"grpc.http2.hpack_table_size.encoder"
|
141
|
+
/** Default authority to pass if none specified on call construction */
|
142
|
+
#define GRPC_ARG_DEFAULT_AUTHORITY "grpc.default_authority"
|
143
|
+
/** Primary user agent: goes at the start of the user-agent metadata
|
144
|
+
sent on each request */
|
145
|
+
#define GRPC_ARG_PRIMARY_USER_AGENT_STRING "grpc.primary_user_agent"
|
146
|
+
/** Secondary user agent: goes at the end of the user-agent metadata
|
147
|
+
sent on each request */
|
148
|
+
#define GRPC_ARG_SECONDARY_USER_AGENT_STRING "grpc.secondary_user_agent"
|
149
|
+
/* The caller of the secure_channel_create functions may override the target
|
150
|
+
name used for SSL host name checking using this channel argument which is of
|
151
|
+
type GRPC_ARG_STRING. This *should* be used for testing only.
|
152
|
+
If this argument is not specified, the name used for SSL host name checking
|
153
|
+
will be the target parameter (assuming that the secure channel is an SSL
|
154
|
+
channel). If this parameter is specified and the underlying is not an SSL
|
155
|
+
channel, it will just be ignored. */
|
156
|
+
#define GRPC_SSL_TARGET_NAME_OVERRIDE_ARG "grpc.ssl_target_name_override"
|
157
|
+
|
158
|
+
/** Connectivity state of a channel. */
|
159
|
+
typedef enum {
|
160
|
+
/** channel is idle */
|
161
|
+
GRPC_CHANNEL_IDLE,
|
162
|
+
/** channel is connecting */
|
163
|
+
GRPC_CHANNEL_CONNECTING,
|
164
|
+
/** channel is ready for work */
|
165
|
+
GRPC_CHANNEL_READY,
|
166
|
+
/** channel has seen a failure but expects to recover */
|
167
|
+
GRPC_CHANNEL_TRANSIENT_FAILURE,
|
168
|
+
/** channel has seen a failure that it cannot recover from */
|
169
|
+
GRPC_CHANNEL_FATAL_FAILURE
|
170
|
+
} grpc_connectivity_state;
|
171
|
+
|
172
|
+
/** Result of a grpc call. If the caller satisfies the prerequisites of a
|
173
|
+
particular operation, the grpc_call_error returned will be GRPC_CALL_OK.
|
174
|
+
Receiving any other value listed here is an indication of a bug in the
|
175
|
+
caller. */
|
176
|
+
typedef enum grpc_call_error {
|
177
|
+
/** everything went ok */
|
178
|
+
GRPC_CALL_OK = 0,
|
179
|
+
/** something failed, we don't know what */
|
180
|
+
GRPC_CALL_ERROR,
|
181
|
+
/** this method is not available on the server */
|
182
|
+
GRPC_CALL_ERROR_NOT_ON_SERVER,
|
183
|
+
/** this method is not available on the client */
|
184
|
+
GRPC_CALL_ERROR_NOT_ON_CLIENT,
|
185
|
+
/** this method must be called before server_accept */
|
186
|
+
GRPC_CALL_ERROR_ALREADY_ACCEPTED,
|
187
|
+
/** this method must be called before invoke */
|
188
|
+
GRPC_CALL_ERROR_ALREADY_INVOKED,
|
189
|
+
/** this method must be called after invoke */
|
190
|
+
GRPC_CALL_ERROR_NOT_INVOKED,
|
191
|
+
/** this call is already finished
|
192
|
+
(writes_done or write_status has already been called) */
|
193
|
+
GRPC_CALL_ERROR_ALREADY_FINISHED,
|
194
|
+
/** there is already an outstanding read/write operation on the call */
|
195
|
+
GRPC_CALL_ERROR_TOO_MANY_OPERATIONS,
|
196
|
+
/** the flags value was illegal for this call */
|
197
|
+
GRPC_CALL_ERROR_INVALID_FLAGS,
|
198
|
+
/** invalid metadata was passed to this call */
|
199
|
+
GRPC_CALL_ERROR_INVALID_METADATA,
|
200
|
+
/** invalid message was passed to this call */
|
201
|
+
GRPC_CALL_ERROR_INVALID_MESSAGE,
|
202
|
+
/** completion queue for notification has not been registered with the
|
203
|
+
server */
|
204
|
+
GRPC_CALL_ERROR_NOT_SERVER_COMPLETION_QUEUE,
|
205
|
+
/** this batch of operations leads to more operations than allowed */
|
206
|
+
GRPC_CALL_ERROR_BATCH_TOO_BIG
|
207
|
+
} grpc_call_error;
|
208
|
+
|
209
|
+
/* Write Flags: */
|
210
|
+
/** Hint that the write may be buffered and need not go out on the wire
|
211
|
+
immediately. GRPC is free to buffer the message until the next non-buffered
|
212
|
+
write, or until writes_done, but it need not buffer completely or at all. */
|
213
|
+
#define GRPC_WRITE_BUFFER_HINT (0x00000001u)
|
214
|
+
/** Force compression to be disabled for a particular write
|
215
|
+
(start_write/add_metadata). Illegal on invoke/accept. */
|
216
|
+
#define GRPC_WRITE_NO_COMPRESS (0x00000002u)
|
217
|
+
/** Mask of all valid flags. */
|
218
|
+
#define GRPC_WRITE_USED_MASK (GRPC_WRITE_BUFFER_HINT | GRPC_WRITE_NO_COMPRESS)
|
219
|
+
|
220
|
+
/** A single metadata element */
|
221
|
+
typedef struct grpc_metadata {
|
222
|
+
const char *key;
|
223
|
+
const char *value;
|
224
|
+
size_t value_length;
|
225
|
+
gpr_uint32 flags;
|
226
|
+
|
227
|
+
/** The following fields are reserved for grpc internal use.
|
228
|
+
There is no need to initialize them, and they will be set to garbage
|
229
|
+
during calls to grpc. */
|
230
|
+
struct {
|
231
|
+
void *obfuscated[4];
|
232
|
+
} internal_data;
|
233
|
+
} grpc_metadata;
|
234
|
+
|
235
|
+
/** The type of completion (for grpc_event) */
|
236
|
+
typedef enum grpc_completion_type {
|
237
|
+
/** Shutting down */
|
238
|
+
GRPC_QUEUE_SHUTDOWN,
|
239
|
+
/** No event before timeout */
|
240
|
+
GRPC_QUEUE_TIMEOUT,
|
241
|
+
/** Operation completion */
|
242
|
+
GRPC_OP_COMPLETE
|
243
|
+
} grpc_completion_type;
|
244
|
+
|
245
|
+
/** The result of an operation.
|
246
|
+
|
247
|
+
Returned by a completion queue when the operation started with tag. */
|
248
|
+
typedef struct grpc_event {
|
249
|
+
/** The type of the completion. */
|
250
|
+
grpc_completion_type type;
|
251
|
+
/** non-zero if the operation was successful, 0 upon failure.
|
252
|
+
Only GRPC_OP_COMPLETE can succeed or fail. */
|
253
|
+
int success;
|
254
|
+
/** The tag passed to grpc_call_start_batch etc to start this operation.
|
255
|
+
Only GRPC_OP_COMPLETE has a tag. */
|
256
|
+
void *tag;
|
257
|
+
} grpc_event;
|
258
|
+
|
259
|
+
typedef struct {
|
260
|
+
size_t count;
|
261
|
+
size_t capacity;
|
262
|
+
grpc_metadata *metadata;
|
263
|
+
} grpc_metadata_array;
|
264
|
+
|
265
|
+
void grpc_metadata_array_init(grpc_metadata_array *array);
|
266
|
+
void grpc_metadata_array_destroy(grpc_metadata_array *array);
|
267
|
+
|
268
|
+
typedef struct {
|
269
|
+
char *method;
|
270
|
+
size_t method_capacity;
|
271
|
+
char *host;
|
272
|
+
size_t host_capacity;
|
273
|
+
gpr_timespec deadline;
|
274
|
+
void *reserved;
|
275
|
+
} grpc_call_details;
|
276
|
+
|
277
|
+
void grpc_call_details_init(grpc_call_details *details);
|
278
|
+
void grpc_call_details_destroy(grpc_call_details *details);
|
279
|
+
|
280
|
+
typedef enum {
|
281
|
+
/** Send initial metadata: one and only one instance MUST be sent for each
|
282
|
+
call, unless the call was cancelled - in which case this can be skipped.
|
283
|
+
This op completes after all bytes of metadata have been accepted by
|
284
|
+
outgoing flow control. */
|
285
|
+
GRPC_OP_SEND_INITIAL_METADATA = 0,
|
286
|
+
/** Send a message: 0 or more of these operations can occur for each call.
|
287
|
+
This op completes after all bytes for the message have been accepted by
|
288
|
+
outgoing flow control. */
|
289
|
+
GRPC_OP_SEND_MESSAGE,
|
290
|
+
/** Send a close from the client: one and only one instance MUST be sent from
|
291
|
+
the client, unless the call was cancelled - in which case this can be
|
292
|
+
skipped.
|
293
|
+
This op completes after all bytes for the call (including the close)
|
294
|
+
have passed outgoing flow control. */
|
295
|
+
GRPC_OP_SEND_CLOSE_FROM_CLIENT,
|
296
|
+
/** Send status from the server: one and only one instance MUST be sent from
|
297
|
+
the server unless the call was cancelled - in which case this can be
|
298
|
+
skipped.
|
299
|
+
This op completes after all bytes for the call (including the status)
|
300
|
+
have passed outgoing flow control. */
|
301
|
+
GRPC_OP_SEND_STATUS_FROM_SERVER,
|
302
|
+
/** Receive initial metadata: one and only one MUST be made on the client,
|
303
|
+
must not be made on the server.
|
304
|
+
This op completes after all initial metadata has been read from the
|
305
|
+
peer. */
|
306
|
+
GRPC_OP_RECV_INITIAL_METADATA,
|
307
|
+
/** Receive a message: 0 or more of these operations can occur for each call.
|
308
|
+
This op completes after all bytes of the received message have been
|
309
|
+
read, or after a half-close has been received on this call. */
|
310
|
+
GRPC_OP_RECV_MESSAGE,
|
311
|
+
/** Receive status on the client: one and only one must be made on the client.
|
312
|
+
This operation always succeeds, meaning ops paired with this operation
|
313
|
+
will also appear to succeed, even though they may not have. In that case
|
314
|
+
the status will indicate some failure.
|
315
|
+
This op completes after all activity on the call has completed. */
|
316
|
+
GRPC_OP_RECV_STATUS_ON_CLIENT,
|
317
|
+
/** Receive close on the server: one and only one must be made on the
|
318
|
+
server.
|
319
|
+
This op completes after the close has been received by the server. */
|
320
|
+
GRPC_OP_RECV_CLOSE_ON_SERVER
|
321
|
+
} grpc_op_type;
|
322
|
+
|
323
|
+
/** Operation data: one field for each op type (except SEND_CLOSE_FROM_CLIENT
|
324
|
+
which has no arguments) */
|
325
|
+
typedef struct grpc_op {
|
326
|
+
/** Operation type, as defined by grpc_op_type */
|
327
|
+
grpc_op_type op;
|
328
|
+
/** Write flags bitset for grpc_begin_messages */
|
329
|
+
gpr_uint32 flags;
|
330
|
+
/** Reserved for future usage */
|
331
|
+
void *reserved;
|
332
|
+
union {
|
333
|
+
/** Reserved for future usage */
|
334
|
+
struct {
|
335
|
+
void *reserved[8];
|
336
|
+
} reserved;
|
337
|
+
struct {
|
338
|
+
size_t count;
|
339
|
+
grpc_metadata *metadata;
|
340
|
+
} send_initial_metadata;
|
341
|
+
grpc_byte_buffer *send_message;
|
342
|
+
struct {
|
343
|
+
size_t trailing_metadata_count;
|
344
|
+
grpc_metadata *trailing_metadata;
|
345
|
+
grpc_status_code status;
|
346
|
+
const char *status_details;
|
347
|
+
} send_status_from_server;
|
348
|
+
/** ownership of the array is with the caller, but ownership of the elements
|
349
|
+
stays with the call object (ie key, value members are owned by the call
|
350
|
+
object, recv_initial_metadata->array is owned by the caller).
|
351
|
+
After the operation completes, call grpc_metadata_array_destroy on this
|
352
|
+
value, or reuse it in a future op. */
|
353
|
+
grpc_metadata_array *recv_initial_metadata;
|
354
|
+
/** ownership of the byte buffer is moved to the caller; the caller must
|
355
|
+
call grpc_byte_buffer_destroy on this value, or reuse it in a future op.
|
356
|
+
*/
|
357
|
+
grpc_byte_buffer **recv_message;
|
358
|
+
struct {
|
359
|
+
/** ownership of the array is with the caller, but ownership of the
|
360
|
+
elements stays with the call object (ie key, value members are owned
|
361
|
+
by the call object, trailing_metadata->array is owned by the caller).
|
362
|
+
After the operation completes, call grpc_metadata_array_destroy on
|
363
|
+
this
|
364
|
+
value, or reuse it in a future op. */
|
365
|
+
grpc_metadata_array *trailing_metadata;
|
366
|
+
grpc_status_code *status;
|
367
|
+
/** status_details is a buffer owned by the application before the op
|
368
|
+
completes and after the op has completed. During the operation
|
369
|
+
status_details may be reallocated to a size larger than
|
370
|
+
*status_details_capacity, in which case *status_details_capacity will
|
371
|
+
be updated with the new array capacity.
|
372
|
+
|
373
|
+
Pre-allocating space:
|
374
|
+
size_t my_capacity = 8;
|
375
|
+
char *my_details = gpr_malloc(my_capacity);
|
376
|
+
x.status_details = &my_details;
|
377
|
+
x.status_details_capacity = &my_capacity;
|
378
|
+
|
379
|
+
Not pre-allocating space:
|
380
|
+
size_t my_capacity = 0;
|
381
|
+
char *my_details = NULL;
|
382
|
+
x.status_details = &my_details;
|
383
|
+
x.status_details_capacity = &my_capacity;
|
384
|
+
|
385
|
+
After the call:
|
386
|
+
gpr_free(my_details); */
|
387
|
+
char **status_details;
|
388
|
+
size_t *status_details_capacity;
|
389
|
+
} recv_status_on_client;
|
390
|
+
struct {
|
391
|
+
/** out argument, set to 1 if the call failed in any way (seen as a
|
392
|
+
cancellation on the server), or 0 if the call succeeded */
|
393
|
+
int *cancelled;
|
394
|
+
} recv_close_on_server;
|
395
|
+
} data;
|
396
|
+
} grpc_op;
|
397
|
+
|
398
|
+
/** Registers a plugin to be initialized and destroyed with the library.
|
399
|
+
|
400
|
+
The \a init and \a destroy functions will be invoked as part of
|
401
|
+
\a grpc_init() and \a grpc_shutdown(), respectively.
|
402
|
+
Note that these functions can be invoked an arbitrary number of times
|
403
|
+
(and hence so will \a init and \a destroy).
|
404
|
+
It is safe to pass NULL to either argument. Plugins are destroyed in
|
405
|
+
the reverse order they were initialized. */
|
406
|
+
void grpc_register_plugin(void (*init)(void), void (*destroy)(void));
|
407
|
+
|
408
|
+
/* Propagation bits: this can be bitwise or-ed to form propagation_mask for
|
409
|
+
* grpc_call */
|
410
|
+
/** Propagate deadline */
|
411
|
+
#define GRPC_PROPAGATE_DEADLINE ((gpr_uint32)1)
|
412
|
+
/** Propagate census context */
|
413
|
+
#define GRPC_PROPAGATE_CENSUS_STATS_CONTEXT ((gpr_uint32)2)
|
414
|
+
#define GRPC_PROPAGATE_CENSUS_TRACING_CONTEXT ((gpr_uint32)4)
|
415
|
+
/** Propagate cancellation */
|
416
|
+
#define GRPC_PROPAGATE_CANCELLATION ((gpr_uint32)8)
|
417
|
+
|
418
|
+
/* Default propagation mask: clients of the core API are encouraged to encode
|
419
|
+
deltas from this in their implementations... ie write:
|
420
|
+
GRPC_PROPAGATE_DEFAULTS & ~GRPC_PROPAGATE_DEADLINE to disable deadline
|
421
|
+
propagation. Doing so gives flexibility in the future to define new
|
422
|
+
propagation types that are default inherited or not. */
|
423
|
+
#define GRPC_PROPAGATE_DEFAULTS \
|
424
|
+
((gpr_uint32)(( \
|
425
|
+
0xffff | GRPC_PROPAGATE_DEADLINE | GRPC_PROPAGATE_CENSUS_STATS_CONTEXT | \
|
426
|
+
GRPC_PROPAGATE_CENSUS_TRACING_CONTEXT | GRPC_PROPAGATE_CANCELLATION)))
|
427
|
+
|
428
|
+
/** Initialize the grpc library.
|
429
|
+
|
430
|
+
It is not safe to call any other grpc functions before calling this.
|
431
|
+
(To avoid overhead, little checking is done, and some things may work. We
|
432
|
+
do not warrant that they will continue to do so in future revisions of this
|
433
|
+
library). */
|
434
|
+
void grpc_init(void);
|
435
|
+
|
436
|
+
/** Shut down the grpc library.
|
437
|
+
|
438
|
+
No memory is used by grpc after this call returns, nor are any instructions
|
439
|
+
executing within the grpc library.
|
440
|
+
Prior to calling, all application owned grpc objects must have been
|
441
|
+
destroyed. */
|
442
|
+
void grpc_shutdown(void);
|
443
|
+
|
444
|
+
/** Return a string representing the current version of grpc */
|
445
|
+
const char *grpc_version_string(void);
|
446
|
+
|
447
|
+
/** Create a completion queue */
|
448
|
+
grpc_completion_queue *grpc_completion_queue_create(void *reserved);
|
449
|
+
|
450
|
+
/** Blocks until an event is available, the completion queue is being shut down,
|
451
|
+
or deadline is reached.
|
452
|
+
|
453
|
+
Returns a grpc_event with type GRPC_QUEUE_TIMEOUT on timeout,
|
454
|
+
otherwise a grpc_event describing the event that occurred.
|
455
|
+
|
456
|
+
Callers must not call grpc_completion_queue_next and
|
457
|
+
grpc_completion_queue_pluck simultaneously on the same completion queue. */
|
458
|
+
grpc_event grpc_completion_queue_next(grpc_completion_queue *cq,
|
459
|
+
gpr_timespec deadline, void *reserved);
|
460
|
+
|
461
|
+
/** Blocks until an event with tag 'tag' is available, the completion queue is
|
462
|
+
being shutdown or deadline is reached.
|
463
|
+
|
464
|
+
Returns a grpc_event with type GRPC_QUEUE_TIMEOUT on timeout,
|
465
|
+
otherwise a grpc_event describing the event that occurred.
|
466
|
+
|
467
|
+
Callers must not call grpc_completion_queue_next and
|
468
|
+
grpc_completion_queue_pluck simultaneously on the same completion queue.
|
469
|
+
|
470
|
+
Completion queues support a maximum of GRPC_MAX_COMPLETION_QUEUE_PLUCKERS
|
471
|
+
concurrently executing plucks at any time. */
|
472
|
+
grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cq, void *tag,
|
473
|
+
gpr_timespec deadline, void *reserved);
|
474
|
+
|
475
|
+
/** Maximum number of outstanding grpc_completion_queue_pluck executions per
|
476
|
+
completion queue */
|
477
|
+
#define GRPC_MAX_COMPLETION_QUEUE_PLUCKERS 6
|
478
|
+
|
479
|
+
/** Begin destruction of a completion queue. Once all possible events are
|
480
|
+
drained then grpc_completion_queue_next will start to produce
|
481
|
+
GRPC_QUEUE_SHUTDOWN events only. At that point it's safe to call
|
482
|
+
grpc_completion_queue_destroy.
|
483
|
+
|
484
|
+
After calling this function applications should ensure that no
|
485
|
+
NEW work is added to be published on this completion queue. */
|
486
|
+
void grpc_completion_queue_shutdown(grpc_completion_queue *cq);
|
487
|
+
|
488
|
+
/** Destroy a completion queue. The caller must ensure that the queue is
|
489
|
+
drained and no threads are executing grpc_completion_queue_next */
|
490
|
+
void grpc_completion_queue_destroy(grpc_completion_queue *cq);
|
491
|
+
|
492
|
+
/** Create a completion queue alarm instance associated to \a cq.
|
493
|
+
*
|
494
|
+
* Once the alarm expires (at \a deadline) or it's cancelled (see \a
|
495
|
+
* grpc_alarm_cancel), an event with tag \a tag will be added to \a cq. If the
|
496
|
+
* alarm expired, the event's success bit will be true, false otherwise (ie,
|
497
|
+
* upon cancellation). */
|
498
|
+
grpc_alarm *grpc_alarm_create(grpc_completion_queue *cq, gpr_timespec deadline,
|
499
|
+
void *tag);
|
500
|
+
|
501
|
+
/** Cancel a completion queue alarm. Calling this function over an alarm that
|
502
|
+
* has already fired has no effect. */
|
503
|
+
void grpc_alarm_cancel(grpc_alarm *alarm);
|
504
|
+
|
505
|
+
/** Destroy the given completion queue alarm, cancelling it in the process. */
|
506
|
+
void grpc_alarm_destroy(grpc_alarm *alarm);
|
507
|
+
|
508
|
+
/** Check the connectivity state of a channel. */
|
509
|
+
grpc_connectivity_state grpc_channel_check_connectivity_state(
|
510
|
+
grpc_channel *channel, int try_to_connect);
|
511
|
+
|
512
|
+
/** Watch for a change in connectivity state.
|
513
|
+
Once the channel connectivity state is different from last_observed_state,
|
514
|
+
tag will be enqueued on cq with success=1.
|
515
|
+
If deadline expires BEFORE the state is changed, tag will be enqueued on cq
|
516
|
+
with success=0. */
|
517
|
+
void grpc_channel_watch_connectivity_state(
|
518
|
+
grpc_channel *channel, grpc_connectivity_state last_observed_state,
|
519
|
+
gpr_timespec deadline, grpc_completion_queue *cq, void *tag);
|
520
|
+
|
521
|
+
/** Create a call given a grpc_channel, in order to call 'method'. All
|
522
|
+
completions are sent to 'completion_queue'. 'method' and 'host' need only
|
523
|
+
live through the invocation of this function.
|
524
|
+
If parent_call is non-NULL, it must be a server-side call. It will be used
|
525
|
+
to propagate properties from the server call to this new client call.
|
526
|
+
*/
|
527
|
+
grpc_call *grpc_channel_create_call(grpc_channel *channel,
|
528
|
+
grpc_call *parent_call,
|
529
|
+
gpr_uint32 propagation_mask,
|
530
|
+
grpc_completion_queue *completion_queue,
|
531
|
+
const char *method, const char *host,
|
532
|
+
gpr_timespec deadline, void *reserved);
|
533
|
+
|
534
|
+
/** Ping the channels peer (load balanced channels will select one sub-channel
|
535
|
+
to ping); if the channel is not connected, posts a failed. */
|
536
|
+
void grpc_channel_ping(grpc_channel *channel, grpc_completion_queue *cq,
|
537
|
+
void *tag, void *reserved);
|
538
|
+
|
539
|
+
/** Pre-register a method/host pair on a channel. */
|
540
|
+
void *grpc_channel_register_call(grpc_channel *channel, const char *method,
|
541
|
+
const char *host, void *reserved);
|
542
|
+
|
543
|
+
/** Create a call given a handle returned from grpc_channel_register_call */
|
544
|
+
grpc_call *grpc_channel_create_registered_call(
|
545
|
+
grpc_channel *channel, grpc_call *parent_call, gpr_uint32 propagation_mask,
|
546
|
+
grpc_completion_queue *completion_queue, void *registered_call_handle,
|
547
|
+
gpr_timespec deadline, void *reserved);
|
548
|
+
|
549
|
+
/** Start a batch of operations defined in the array ops; when complete, post a
|
550
|
+
completion of type 'tag' to the completion queue bound to the call.
|
551
|
+
The order of ops specified in the batch has no significance.
|
552
|
+
Only one operation of each type can be active at once in any given
|
553
|
+
batch. You must call grpc_completion_queue_next or
|
554
|
+
grpc_completion_queue_pluck on the completion queue associated with 'call'
|
555
|
+
for work to be performed.
|
556
|
+
THREAD SAFETY: access to grpc_call_start_batch in multi-threaded environment
|
557
|
+
needs to be synchronized. As an optimization, you may synchronize batches
|
558
|
+
containing just send operations independently from batches containing just
|
559
|
+
receive operations. */
|
560
|
+
grpc_call_error grpc_call_start_batch(grpc_call *call, const grpc_op *ops,
|
561
|
+
size_t nops, void *tag, void *reserved);
|
562
|
+
|
563
|
+
/** Returns a newly allocated string representing the endpoint to which this
|
564
|
+
call is communicating with. The string is in the uri format accepted by
|
565
|
+
grpc_channel_create.
|
566
|
+
The returned string should be disposed of with gpr_free().
|
567
|
+
|
568
|
+
WARNING: this value is never authenticated or subject to any security
|
569
|
+
related code. It must not be used for any authentication related
|
570
|
+
functionality. Instead, use grpc_auth_context. */
|
571
|
+
char *grpc_call_get_peer(grpc_call *call);
|
572
|
+
|
573
|
+
struct census_context;
|
574
|
+
|
575
|
+
/* Set census context for a call; Must be called before first call to
|
576
|
+
grpc_call_start_batch(). */
|
577
|
+
void grpc_census_call_set_context(grpc_call *call,
|
578
|
+
struct census_context *context);
|
579
|
+
|
580
|
+
/* Retrieve the calls current census context. */
|
581
|
+
struct census_context *grpc_census_call_get_context(grpc_call *call);
|
582
|
+
|
583
|
+
/** Return a newly allocated string representing the target a channel was
|
584
|
+
created for. */
|
585
|
+
char *grpc_channel_get_target(grpc_channel *channel);
|
586
|
+
|
587
|
+
/** Create a client channel to 'target'. Additional channel level configuration
|
588
|
+
MAY be provided by grpc_channel_args, though the expectation is that most
|
589
|
+
clients will want to simply pass NULL. See grpc_channel_args definition for
|
590
|
+
more on this. The data in 'args' need only live through the invocation of
|
591
|
+
this function. */
|
592
|
+
grpc_channel *grpc_insecure_channel_create(const char *target,
|
593
|
+
const grpc_channel_args *args,
|
594
|
+
void *reserved);
|
595
|
+
|
596
|
+
/** Create a lame client: this client fails every operation attempted on it. */
|
597
|
+
grpc_channel *grpc_lame_client_channel_create(const char *target,
|
598
|
+
grpc_status_code error_code,
|
599
|
+
const char *error_message);
|
600
|
+
|
601
|
+
/** Close and destroy a grpc channel */
|
602
|
+
void grpc_channel_destroy(grpc_channel *channel);
|
603
|
+
|
604
|
+
/* Error handling for grpc_call
|
605
|
+
Most grpc_call functions return a grpc_error. If the error is not GRPC_OK
|
606
|
+
then the operation failed due to some unsatisfied precondition.
|
607
|
+
If a grpc_call fails, it's guaranteed that no change to the call state
|
608
|
+
has been made. */
|
609
|
+
|
610
|
+
/** Called by clients to cancel an RPC on the server.
|
611
|
+
Can be called multiple times, from any thread.
|
612
|
+
THREAD-SAFETY grpc_call_cancel and grpc_call_cancel_with_status
|
613
|
+
are thread-safe, and can be called at any point before grpc_call_destroy
|
614
|
+
is called.*/
|
615
|
+
grpc_call_error grpc_call_cancel(grpc_call *call, void *reserved);
|
616
|
+
|
617
|
+
/** Called by clients to cancel an RPC on the server.
|
618
|
+
Can be called multiple times, from any thread.
|
619
|
+
If a status has not been received for the call, set it to the status code
|
620
|
+
and description passed in.
|
621
|
+
Importantly, this function does not send status nor description to the
|
622
|
+
remote endpoint. */
|
623
|
+
grpc_call_error grpc_call_cancel_with_status(grpc_call *call,
|
624
|
+
grpc_status_code status,
|
625
|
+
const char *description,
|
626
|
+
void *reserved);
|
627
|
+
|
628
|
+
/** Destroy a call.
|
629
|
+
THREAD SAFETY: grpc_call_destroy is thread-compatible */
|
630
|
+
void grpc_call_destroy(grpc_call *call);
|
631
|
+
|
632
|
+
/** Request notification of a new call.
|
633
|
+
Once a call is received, a notification tagged with \a tag_new is added to
|
634
|
+
\a cq_for_notification. \a call, \a details and \a request_metadata are
|
635
|
+
updated with the appropriate call information. \a cq_bound_to_call is bound
|
636
|
+
to \a call, and batch operation notifications for that call will be posted
|
637
|
+
to \a cq_bound_to_call.
|
638
|
+
Note that \a cq_for_notification must have been registered to the server via
|
639
|
+
\a grpc_server_register_completion_queue. */
|
640
|
+
grpc_call_error grpc_server_request_call(
|
641
|
+
grpc_server *server, grpc_call **call, grpc_call_details *details,
|
642
|
+
grpc_metadata_array *request_metadata,
|
643
|
+
grpc_completion_queue *cq_bound_to_call,
|
644
|
+
grpc_completion_queue *cq_for_notification, void *tag_new);
|
645
|
+
|
646
|
+
/** Registers a method in the server.
|
647
|
+
Methods to this (host, method) pair will not be reported by
|
648
|
+
grpc_server_request_call, but instead be reported by
|
649
|
+
grpc_server_request_registered_call when passed the appropriate
|
650
|
+
registered_method (as returned by this function).
|
651
|
+
Must be called before grpc_server_start.
|
652
|
+
Returns NULL on failure. */
|
653
|
+
void *grpc_server_register_method(grpc_server *server, const char *method,
|
654
|
+
const char *host);
|
655
|
+
|
656
|
+
/** Request notification of a new pre-registered call. 'cq_for_notification'
|
657
|
+
must have been registered to the server via
|
658
|
+
grpc_server_register_completion_queue. */
|
659
|
+
grpc_call_error grpc_server_request_registered_call(
|
660
|
+
grpc_server *server, void *registered_method, grpc_call **call,
|
661
|
+
gpr_timespec *deadline, grpc_metadata_array *request_metadata,
|
662
|
+
grpc_byte_buffer **optional_payload,
|
663
|
+
grpc_completion_queue *cq_bound_to_call,
|
664
|
+
grpc_completion_queue *cq_for_notification, void *tag_new);
|
665
|
+
|
666
|
+
/** Create a server. Additional configuration for each incoming channel can
|
667
|
+
be specified with args. If no additional configuration is needed, args can
|
668
|
+
be NULL. See grpc_channel_args for more. The data in 'args' need only live
|
669
|
+
through the invocation of this function. */
|
670
|
+
grpc_server *grpc_server_create(const grpc_channel_args *args, void *reserved);
|
671
|
+
|
672
|
+
/** Register a completion queue with the server. Must be done for any
|
673
|
+
notification completion queue that is passed to grpc_server_request_*_call
|
674
|
+
and to grpc_server_shutdown_and_notify. Must be performed prior to
|
675
|
+
grpc_server_start. */
|
676
|
+
void grpc_server_register_completion_queue(grpc_server *server,
|
677
|
+
grpc_completion_queue *cq,
|
678
|
+
void *reserved);
|
679
|
+
|
680
|
+
/** Add a HTTP2 over plaintext over tcp listener.
|
681
|
+
Returns bound port number on success, 0 on failure.
|
682
|
+
REQUIRES: server not started */
|
683
|
+
int grpc_server_add_insecure_http2_port(grpc_server *server, const char *addr);
|
684
|
+
|
685
|
+
/** Start a server - tells all listeners to start listening */
|
686
|
+
void grpc_server_start(grpc_server *server);
|
687
|
+
|
688
|
+
/** Begin shutting down a server.
|
689
|
+
After completion, no new calls or connections will be admitted.
|
690
|
+
Existing calls will be allowed to complete.
|
691
|
+
Send a GRPC_OP_COMPLETE event when there are no more calls being serviced.
|
692
|
+
Shutdown is idempotent, and all tags will be notified at once if multiple
|
693
|
+
grpc_server_shutdown_and_notify calls are made. 'cq' must have been
|
694
|
+
registered to this server via grpc_server_register_completion_queue. */
|
695
|
+
void grpc_server_shutdown_and_notify(grpc_server *server,
|
696
|
+
grpc_completion_queue *cq, void *tag);
|
697
|
+
|
698
|
+
/** Cancel all in-progress calls.
|
699
|
+
Only usable after shutdown. */
|
700
|
+
void grpc_server_cancel_all_calls(grpc_server *server);
|
701
|
+
|
702
|
+
/** Destroy a server.
|
703
|
+
Shutdown must have completed beforehand (i.e. all tags generated by
|
704
|
+
grpc_server_shutdown_and_notify must have been received, and at least
|
705
|
+
one call to grpc_server_shutdown_and_notify must have been made). */
|
706
|
+
void grpc_server_destroy(grpc_server *server);
|
707
|
+
|
708
|
+
/** Enable or disable a tracer.
|
709
|
+
|
710
|
+
Tracers (usually controlled by the environment variable GRPC_TRACE)
|
711
|
+
allow printf-style debugging on GRPC internals, and are useful for
|
712
|
+
tracking down problems in the field.
|
713
|
+
|
714
|
+
Use of this function is not strictly thread-safe, but the
|
715
|
+
thread-safety issues raised by it should not be of concern. */
|
716
|
+
int grpc_tracer_set_enabled(const char *name, int enabled);
|
717
|
+
|
718
|
+
/** Check whether a metadata key is legal (will be accepted by core) */
|
719
|
+
int grpc_header_key_is_legal(const char *key, size_t length);
|
720
|
+
|
721
|
+
/** Check whether a non-binary metadata value is legal (will be accepted by
|
722
|
+
core) */
|
723
|
+
int grpc_header_nonbin_value_is_legal(const char *value, size_t length);
|
724
|
+
|
725
|
+
/** Check whether a metadata key corresponds to a binary value */
|
726
|
+
int grpc_is_binary_header(const char *key, size_t length);
|
727
|
+
|
728
|
+
#ifdef __cplusplus
|
729
|
+
}
|
730
|
+
#endif
|
731
|
+
|
732
|
+
#endif /* GRPC_GRPC_H */
|