grpc 1.6.7-x64-mingw32 → 1.7.0.pre1-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/grpc_c.32.ruby +0 -0
  3. data/grpc_c.64.ruby +0 -0
  4. data/src/ruby/ext/grpc/rb_call_credentials.c +6 -2
  5. data/src/ruby/ext/grpc/rb_grpc.c +1 -1
  6. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +30 -20
  7. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +50 -35
  8. data/src/ruby/lib/grpc.rb +1 -0
  9. data/src/ruby/lib/grpc/2.0/grpc_c.so +0 -0
  10. data/src/ruby/lib/grpc/2.1/grpc_c.so +0 -0
  11. data/src/ruby/lib/grpc/2.2/grpc_c.so +0 -0
  12. data/src/ruby/lib/grpc/2.3/grpc_c.so +0 -0
  13. data/src/ruby/lib/grpc/2.4/grpc_c.so +0 -0
  14. data/src/ruby/lib/grpc/generic/active_call.rb +34 -9
  15. data/src/ruby/lib/grpc/generic/bidi_call.rb +19 -10
  16. data/src/ruby/lib/grpc/generic/client_stub.rb +95 -38
  17. data/src/ruby/lib/grpc/generic/interceptor_registry.rb +53 -0
  18. data/src/ruby/lib/grpc/generic/interceptors.rb +186 -0
  19. data/src/ruby/lib/grpc/generic/rpc_desc.rb +66 -20
  20. data/src/ruby/lib/grpc/generic/rpc_server.rb +15 -3
  21. data/src/ruby/lib/grpc/google_rpc_status_utils.rb +1 -2
  22. data/src/ruby/lib/grpc/grpc_c.so +0 -0
  23. data/src/ruby/lib/grpc/version.rb +1 -1
  24. data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb +1 -0
  25. data/src/ruby/spec/channel_connection_spec.rb +1 -34
  26. data/src/ruby/spec/client_server_spec.rb +188 -82
  27. data/src/ruby/spec/generic/active_call_spec.rb +65 -11
  28. data/src/ruby/spec/generic/client_interceptors_spec.rb +153 -0
  29. data/src/ruby/spec/generic/interceptor_registry_spec.rb +65 -0
  30. data/src/ruby/spec/generic/rpc_desc_spec.rb +38 -0
  31. data/src/ruby/spec/generic/rpc_server_spec.rb +1 -34
  32. data/src/ruby/spec/generic/server_interceptors_spec.rb +218 -0
  33. data/src/ruby/spec/spec_helper.rb +4 -0
  34. data/src/ruby/spec/support/helpers.rb +73 -0
  35. data/src/ruby/spec/support/services.rb +147 -0
  36. metadata +24 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65a930b54937c9de2fe421873af4000ffc00f716
4
- data.tar.gz: b23bc702b6d967fc7ee0a563358b895422724ea4
3
+ metadata.gz: 9d552993cfe6d709583f6f97f3e432df420aefaf
4
+ data.tar.gz: 966a3541bf2d3b60d68df59d9d9200595c86950e
5
5
  SHA512:
6
- metadata.gz: 4ab345a3f9800307f642ef447135b291547db1c338d487116978462460b1353fc53c8bf7e5c7d35655ed6b27144ea386059cad12a87d7f63995656b1acc163d7
7
- data.tar.gz: 259b58bc841c39afc4f96f964d5fb0e6ce22920d49a5d946a735d2c268b40b9cebd6b3563e30231a9a4321c34737f6e317e5a79b38766a6e2f59dd12970db980
6
+ metadata.gz: ebdbaef7205d1a0af9eb1eff7fb923c1c5b2516169d6c87993db7aa8a8429499fddb383a49aa1ff3d91a9d83fa596451a356157bf51a456e45f7818d709db568
7
+ data.tar.gz: e494b07e49990d29c35e38ebda03823eea3079225923cee60fc2820f7aa676441aa5117f0e99397be49f164315f1393fec6b79b43405e7bb05eb64b3e3b9935a
Binary file
Binary file
@@ -112,9 +112,12 @@ static void grpc_rb_call_credentials_callback_with_gil(void *param) {
112
112
  gpr_free(params);
113
113
  }
114
114
 
115
- static void grpc_rb_call_credentials_plugin_get_metadata(
115
+ static int grpc_rb_call_credentials_plugin_get_metadata(
116
116
  void *state, grpc_auth_metadata_context context,
117
- grpc_credentials_plugin_metadata_cb cb, void *user_data) {
117
+ grpc_credentials_plugin_metadata_cb cb, void *user_data,
118
+ grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX],
119
+ size_t *num_creds_md, grpc_status_code *status,
120
+ const char **error_details) {
118
121
  callback_params *params = gpr_malloc(sizeof(callback_params));
119
122
  params->get_metadata = (VALUE)state;
120
123
  params->context = context;
@@ -123,6 +126,7 @@ static void grpc_rb_call_credentials_plugin_get_metadata(
123
126
 
124
127
  grpc_rb_event_queue_enqueue(grpc_rb_call_credentials_callback_with_gil,
125
128
  (void *)(params));
129
+ return 0; // Async return.
126
130
  }
127
131
 
128
132
  static void grpc_rb_call_credentials_plugin_destroy(void *state) {
@@ -315,8 +315,8 @@ void Init_grpc_c() {
315
315
  return;
316
316
  }
317
317
 
318
- rb_global_variable(&bg_thread_init_rb_mu);
319
318
  bg_thread_init_rb_mu = rb_mutex_new();
319
+ rb_global_variable(&bg_thread_init_rb_mu);
320
320
 
321
321
  grpc_rb_mGRPC = rb_define_module("GRPC");
322
322
  grpc_rb_mGrpcCore = rb_define_module_under(grpc_rb_mGRPC, "Core");
@@ -22,16 +22,6 @@
22
22
 
23
23
  #include "rb_grpc_imports.generated.h"
24
24
 
25
- grpc_raw_byte_buffer_create_type grpc_raw_byte_buffer_create_import;
26
- grpc_raw_compressed_byte_buffer_create_type grpc_raw_compressed_byte_buffer_create_import;
27
- grpc_byte_buffer_copy_type grpc_byte_buffer_copy_import;
28
- grpc_byte_buffer_length_type grpc_byte_buffer_length_import;
29
- grpc_byte_buffer_destroy_type grpc_byte_buffer_destroy_import;
30
- grpc_byte_buffer_reader_init_type grpc_byte_buffer_reader_init_import;
31
- grpc_byte_buffer_reader_destroy_type grpc_byte_buffer_reader_destroy_import;
32
- grpc_byte_buffer_reader_next_type grpc_byte_buffer_reader_next_import;
33
- grpc_byte_buffer_reader_readall_type grpc_byte_buffer_reader_readall_import;
34
- grpc_raw_byte_buffer_from_reader_type grpc_raw_byte_buffer_from_reader_import;
35
25
  census_initialize_type census_initialize_import;
36
26
  census_shutdown_type census_shutdown_import;
37
27
  census_supported_type census_supported_import;
@@ -62,11 +52,14 @@ census_resource_id_type census_resource_id_import;
62
52
  census_record_values_type census_record_values_import;
63
53
  grpc_compression_algorithm_parse_type grpc_compression_algorithm_parse_import;
64
54
  grpc_compression_algorithm_name_type grpc_compression_algorithm_name_import;
55
+ grpc_stream_compression_algorithm_name_type grpc_stream_compression_algorithm_name_import;
65
56
  grpc_compression_algorithm_for_level_type grpc_compression_algorithm_for_level_import;
57
+ grpc_stream_compression_algorithm_for_level_type grpc_stream_compression_algorithm_for_level_import;
66
58
  grpc_compression_options_init_type grpc_compression_options_init_import;
67
59
  grpc_compression_options_enable_algorithm_type grpc_compression_options_enable_algorithm_import;
68
60
  grpc_compression_options_disable_algorithm_type grpc_compression_options_disable_algorithm_import;
69
61
  grpc_compression_options_is_algorithm_enabled_type grpc_compression_options_is_algorithm_enabled_import;
62
+ grpc_compression_options_is_stream_compression_algorithm_enabled_type grpc_compression_options_is_stream_compression_algorithm_enabled_import;
70
63
  grpc_metadata_array_init_type grpc_metadata_array_init_import;
71
64
  grpc_metadata_array_destroy_type grpc_metadata_array_destroy_import;
72
65
  grpc_call_details_init_type grpc_call_details_init_import;
@@ -85,11 +78,13 @@ grpc_completion_queue_pluck_type grpc_completion_queue_pluck_import;
85
78
  grpc_completion_queue_shutdown_type grpc_completion_queue_shutdown_import;
86
79
  grpc_completion_queue_destroy_type grpc_completion_queue_destroy_import;
87
80
  grpc_alarm_create_type grpc_alarm_create_import;
81
+ grpc_alarm_set_type grpc_alarm_set_import;
88
82
  grpc_alarm_cancel_type grpc_alarm_cancel_import;
89
83
  grpc_alarm_destroy_type grpc_alarm_destroy_import;
90
84
  grpc_channel_check_connectivity_state_type grpc_channel_check_connectivity_state_import;
91
85
  grpc_channel_num_external_connectivity_watchers_type grpc_channel_num_external_connectivity_watchers_import;
92
86
  grpc_channel_watch_connectivity_state_type grpc_channel_watch_connectivity_state_import;
87
+ grpc_channel_support_connectivity_watcher_type grpc_channel_support_connectivity_watcher_import;
93
88
  grpc_channel_create_call_type grpc_channel_create_call_import;
94
89
  grpc_channel_ping_type grpc_channel_ping_import;
95
90
  grpc_channel_register_call_type grpc_channel_register_call_import;
@@ -163,6 +158,16 @@ grpc_ssl_server_credentials_create_ex_type grpc_ssl_server_credentials_create_ex
163
158
  grpc_server_add_secure_http2_port_type grpc_server_add_secure_http2_port_import;
164
159
  grpc_call_set_credentials_type grpc_call_set_credentials_import;
165
160
  grpc_server_credentials_set_auth_metadata_processor_type grpc_server_credentials_set_auth_metadata_processor_import;
161
+ grpc_raw_byte_buffer_create_type grpc_raw_byte_buffer_create_import;
162
+ grpc_raw_compressed_byte_buffer_create_type grpc_raw_compressed_byte_buffer_create_import;
163
+ grpc_byte_buffer_copy_type grpc_byte_buffer_copy_import;
164
+ grpc_byte_buffer_length_type grpc_byte_buffer_length_import;
165
+ grpc_byte_buffer_destroy_type grpc_byte_buffer_destroy_import;
166
+ grpc_byte_buffer_reader_init_type grpc_byte_buffer_reader_init_import;
167
+ grpc_byte_buffer_reader_destroy_type grpc_byte_buffer_reader_destroy_import;
168
+ grpc_byte_buffer_reader_next_type grpc_byte_buffer_reader_next_import;
169
+ grpc_byte_buffer_reader_readall_type grpc_byte_buffer_reader_readall_import;
170
+ grpc_raw_byte_buffer_from_reader_type grpc_raw_byte_buffer_from_reader_import;
166
171
  grpc_slice_ref_type grpc_slice_ref_import;
167
172
  grpc_slice_unref_type grpc_slice_unref_import;
168
173
  grpc_slice_copy_type grpc_slice_copy_import;
@@ -325,16 +330,6 @@ gpr_sleep_until_type gpr_sleep_until_import;
325
330
  gpr_timespec_to_micros_type gpr_timespec_to_micros_import;
326
331
 
327
332
  void grpc_rb_load_imports(HMODULE library) {
328
- grpc_raw_byte_buffer_create_import = (grpc_raw_byte_buffer_create_type) GetProcAddress(library, "grpc_raw_byte_buffer_create");
329
- grpc_raw_compressed_byte_buffer_create_import = (grpc_raw_compressed_byte_buffer_create_type) GetProcAddress(library, "grpc_raw_compressed_byte_buffer_create");
330
- grpc_byte_buffer_copy_import = (grpc_byte_buffer_copy_type) GetProcAddress(library, "grpc_byte_buffer_copy");
331
- grpc_byte_buffer_length_import = (grpc_byte_buffer_length_type) GetProcAddress(library, "grpc_byte_buffer_length");
332
- grpc_byte_buffer_destroy_import = (grpc_byte_buffer_destroy_type) GetProcAddress(library, "grpc_byte_buffer_destroy");
333
- grpc_byte_buffer_reader_init_import = (grpc_byte_buffer_reader_init_type) GetProcAddress(library, "grpc_byte_buffer_reader_init");
334
- grpc_byte_buffer_reader_destroy_import = (grpc_byte_buffer_reader_destroy_type) GetProcAddress(library, "grpc_byte_buffer_reader_destroy");
335
- grpc_byte_buffer_reader_next_import = (grpc_byte_buffer_reader_next_type) GetProcAddress(library, "grpc_byte_buffer_reader_next");
336
- grpc_byte_buffer_reader_readall_import = (grpc_byte_buffer_reader_readall_type) GetProcAddress(library, "grpc_byte_buffer_reader_readall");
337
- grpc_raw_byte_buffer_from_reader_import = (grpc_raw_byte_buffer_from_reader_type) GetProcAddress(library, "grpc_raw_byte_buffer_from_reader");
338
333
  census_initialize_import = (census_initialize_type) GetProcAddress(library, "census_initialize");
339
334
  census_shutdown_import = (census_shutdown_type) GetProcAddress(library, "census_shutdown");
340
335
  census_supported_import = (census_supported_type) GetProcAddress(library, "census_supported");
@@ -365,11 +360,14 @@ void grpc_rb_load_imports(HMODULE library) {
365
360
  census_record_values_import = (census_record_values_type) GetProcAddress(library, "census_record_values");
366
361
  grpc_compression_algorithm_parse_import = (grpc_compression_algorithm_parse_type) GetProcAddress(library, "grpc_compression_algorithm_parse");
367
362
  grpc_compression_algorithm_name_import = (grpc_compression_algorithm_name_type) GetProcAddress(library, "grpc_compression_algorithm_name");
363
+ grpc_stream_compression_algorithm_name_import = (grpc_stream_compression_algorithm_name_type) GetProcAddress(library, "grpc_stream_compression_algorithm_name");
368
364
  grpc_compression_algorithm_for_level_import = (grpc_compression_algorithm_for_level_type) GetProcAddress(library, "grpc_compression_algorithm_for_level");
365
+ grpc_stream_compression_algorithm_for_level_import = (grpc_stream_compression_algorithm_for_level_type) GetProcAddress(library, "grpc_stream_compression_algorithm_for_level");
369
366
  grpc_compression_options_init_import = (grpc_compression_options_init_type) GetProcAddress(library, "grpc_compression_options_init");
370
367
  grpc_compression_options_enable_algorithm_import = (grpc_compression_options_enable_algorithm_type) GetProcAddress(library, "grpc_compression_options_enable_algorithm");
371
368
  grpc_compression_options_disable_algorithm_import = (grpc_compression_options_disable_algorithm_type) GetProcAddress(library, "grpc_compression_options_disable_algorithm");
372
369
  grpc_compression_options_is_algorithm_enabled_import = (grpc_compression_options_is_algorithm_enabled_type) GetProcAddress(library, "grpc_compression_options_is_algorithm_enabled");
370
+ grpc_compression_options_is_stream_compression_algorithm_enabled_import = (grpc_compression_options_is_stream_compression_algorithm_enabled_type) GetProcAddress(library, "grpc_compression_options_is_stream_compression_algorithm_enabled");
373
371
  grpc_metadata_array_init_import = (grpc_metadata_array_init_type) GetProcAddress(library, "grpc_metadata_array_init");
374
372
  grpc_metadata_array_destroy_import = (grpc_metadata_array_destroy_type) GetProcAddress(library, "grpc_metadata_array_destroy");
375
373
  grpc_call_details_init_import = (grpc_call_details_init_type) GetProcAddress(library, "grpc_call_details_init");
@@ -388,11 +386,13 @@ void grpc_rb_load_imports(HMODULE library) {
388
386
  grpc_completion_queue_shutdown_import = (grpc_completion_queue_shutdown_type) GetProcAddress(library, "grpc_completion_queue_shutdown");
389
387
  grpc_completion_queue_destroy_import = (grpc_completion_queue_destroy_type) GetProcAddress(library, "grpc_completion_queue_destroy");
390
388
  grpc_alarm_create_import = (grpc_alarm_create_type) GetProcAddress(library, "grpc_alarm_create");
389
+ grpc_alarm_set_import = (grpc_alarm_set_type) GetProcAddress(library, "grpc_alarm_set");
391
390
  grpc_alarm_cancel_import = (grpc_alarm_cancel_type) GetProcAddress(library, "grpc_alarm_cancel");
392
391
  grpc_alarm_destroy_import = (grpc_alarm_destroy_type) GetProcAddress(library, "grpc_alarm_destroy");
393
392
  grpc_channel_check_connectivity_state_import = (grpc_channel_check_connectivity_state_type) GetProcAddress(library, "grpc_channel_check_connectivity_state");
394
393
  grpc_channel_num_external_connectivity_watchers_import = (grpc_channel_num_external_connectivity_watchers_type) GetProcAddress(library, "grpc_channel_num_external_connectivity_watchers");
395
394
  grpc_channel_watch_connectivity_state_import = (grpc_channel_watch_connectivity_state_type) GetProcAddress(library, "grpc_channel_watch_connectivity_state");
395
+ grpc_channel_support_connectivity_watcher_import = (grpc_channel_support_connectivity_watcher_type) GetProcAddress(library, "grpc_channel_support_connectivity_watcher");
396
396
  grpc_channel_create_call_import = (grpc_channel_create_call_type) GetProcAddress(library, "grpc_channel_create_call");
397
397
  grpc_channel_ping_import = (grpc_channel_ping_type) GetProcAddress(library, "grpc_channel_ping");
398
398
  grpc_channel_register_call_import = (grpc_channel_register_call_type) GetProcAddress(library, "grpc_channel_register_call");
@@ -466,6 +466,16 @@ void grpc_rb_load_imports(HMODULE library) {
466
466
  grpc_server_add_secure_http2_port_import = (grpc_server_add_secure_http2_port_type) GetProcAddress(library, "grpc_server_add_secure_http2_port");
467
467
  grpc_call_set_credentials_import = (grpc_call_set_credentials_type) GetProcAddress(library, "grpc_call_set_credentials");
468
468
  grpc_server_credentials_set_auth_metadata_processor_import = (grpc_server_credentials_set_auth_metadata_processor_type) GetProcAddress(library, "grpc_server_credentials_set_auth_metadata_processor");
469
+ grpc_raw_byte_buffer_create_import = (grpc_raw_byte_buffer_create_type) GetProcAddress(library, "grpc_raw_byte_buffer_create");
470
+ grpc_raw_compressed_byte_buffer_create_import = (grpc_raw_compressed_byte_buffer_create_type) GetProcAddress(library, "grpc_raw_compressed_byte_buffer_create");
471
+ grpc_byte_buffer_copy_import = (grpc_byte_buffer_copy_type) GetProcAddress(library, "grpc_byte_buffer_copy");
472
+ grpc_byte_buffer_length_import = (grpc_byte_buffer_length_type) GetProcAddress(library, "grpc_byte_buffer_length");
473
+ grpc_byte_buffer_destroy_import = (grpc_byte_buffer_destroy_type) GetProcAddress(library, "grpc_byte_buffer_destroy");
474
+ grpc_byte_buffer_reader_init_import = (grpc_byte_buffer_reader_init_type) GetProcAddress(library, "grpc_byte_buffer_reader_init");
475
+ grpc_byte_buffer_reader_destroy_import = (grpc_byte_buffer_reader_destroy_type) GetProcAddress(library, "grpc_byte_buffer_reader_destroy");
476
+ grpc_byte_buffer_reader_next_import = (grpc_byte_buffer_reader_next_type) GetProcAddress(library, "grpc_byte_buffer_reader_next");
477
+ grpc_byte_buffer_reader_readall_import = (grpc_byte_buffer_reader_readall_type) GetProcAddress(library, "grpc_byte_buffer_reader_readall");
478
+ grpc_raw_byte_buffer_from_reader_import = (grpc_raw_byte_buffer_from_reader_type) GetProcAddress(library, "grpc_raw_byte_buffer_from_reader");
469
479
  grpc_slice_ref_import = (grpc_slice_ref_type) GetProcAddress(library, "grpc_slice_ref");
470
480
  grpc_slice_unref_import = (grpc_slice_unref_type) GetProcAddress(library, "grpc_slice_unref");
471
481
  grpc_slice_copy_import = (grpc_slice_copy_type) GetProcAddress(library, "grpc_slice_copy");
@@ -25,12 +25,12 @@
25
25
 
26
26
  #include <windows.h>
27
27
 
28
- #include <grpc/byte_buffer.h>
29
28
  #include <grpc/census.h>
30
29
  #include <grpc/compression.h>
31
30
  #include <grpc/grpc.h>
32
31
  #include <grpc/grpc_posix.h>
33
32
  #include <grpc/grpc_security.h>
33
+ #include <grpc/impl/codegen/byte_buffer.h>
34
34
  #include <grpc/slice.h>
35
35
  #include <grpc/slice_buffer.h>
36
36
  #include <grpc/support/alloc.h>
@@ -47,36 +47,6 @@
47
47
  #include <grpc/support/thd.h>
48
48
  #include <grpc/support/time.h>
49
49
 
50
- typedef grpc_byte_buffer *(*grpc_raw_byte_buffer_create_type)(grpc_slice *slices, size_t nslices);
51
- extern grpc_raw_byte_buffer_create_type grpc_raw_byte_buffer_create_import;
52
- #define grpc_raw_byte_buffer_create grpc_raw_byte_buffer_create_import
53
- typedef grpc_byte_buffer *(*grpc_raw_compressed_byte_buffer_create_type)(grpc_slice *slices, size_t nslices, grpc_compression_algorithm compression);
54
- extern grpc_raw_compressed_byte_buffer_create_type grpc_raw_compressed_byte_buffer_create_import;
55
- #define grpc_raw_compressed_byte_buffer_create grpc_raw_compressed_byte_buffer_create_import
56
- typedef grpc_byte_buffer *(*grpc_byte_buffer_copy_type)(grpc_byte_buffer *bb);
57
- extern grpc_byte_buffer_copy_type grpc_byte_buffer_copy_import;
58
- #define grpc_byte_buffer_copy grpc_byte_buffer_copy_import
59
- typedef size_t(*grpc_byte_buffer_length_type)(grpc_byte_buffer *bb);
60
- extern grpc_byte_buffer_length_type grpc_byte_buffer_length_import;
61
- #define grpc_byte_buffer_length grpc_byte_buffer_length_import
62
- typedef void(*grpc_byte_buffer_destroy_type)(grpc_byte_buffer *byte_buffer);
63
- extern grpc_byte_buffer_destroy_type grpc_byte_buffer_destroy_import;
64
- #define grpc_byte_buffer_destroy grpc_byte_buffer_destroy_import
65
- typedef int(*grpc_byte_buffer_reader_init_type)(grpc_byte_buffer_reader *reader, grpc_byte_buffer *buffer);
66
- extern grpc_byte_buffer_reader_init_type grpc_byte_buffer_reader_init_import;
67
- #define grpc_byte_buffer_reader_init grpc_byte_buffer_reader_init_import
68
- typedef void(*grpc_byte_buffer_reader_destroy_type)(grpc_byte_buffer_reader *reader);
69
- extern grpc_byte_buffer_reader_destroy_type grpc_byte_buffer_reader_destroy_import;
70
- #define grpc_byte_buffer_reader_destroy grpc_byte_buffer_reader_destroy_import
71
- typedef int(*grpc_byte_buffer_reader_next_type)(grpc_byte_buffer_reader *reader, grpc_slice *slice);
72
- extern grpc_byte_buffer_reader_next_type grpc_byte_buffer_reader_next_import;
73
- #define grpc_byte_buffer_reader_next grpc_byte_buffer_reader_next_import
74
- typedef grpc_slice(*grpc_byte_buffer_reader_readall_type)(grpc_byte_buffer_reader *reader);
75
- extern grpc_byte_buffer_reader_readall_type grpc_byte_buffer_reader_readall_import;
76
- #define grpc_byte_buffer_reader_readall grpc_byte_buffer_reader_readall_import
77
- typedef grpc_byte_buffer *(*grpc_raw_byte_buffer_from_reader_type)(grpc_byte_buffer_reader *reader);
78
- extern grpc_raw_byte_buffer_from_reader_type grpc_raw_byte_buffer_from_reader_import;
79
- #define grpc_raw_byte_buffer_from_reader grpc_raw_byte_buffer_from_reader_import
80
50
  typedef int(*census_initialize_type)(int features);
81
51
  extern census_initialize_type census_initialize_import;
82
52
  #define census_initialize census_initialize_import
@@ -164,12 +134,18 @@ extern census_record_values_type census_record_values_import;
164
134
  typedef int(*grpc_compression_algorithm_parse_type)(grpc_slice value, grpc_compression_algorithm *algorithm);
165
135
  extern grpc_compression_algorithm_parse_type grpc_compression_algorithm_parse_import;
166
136
  #define grpc_compression_algorithm_parse grpc_compression_algorithm_parse_import
167
- typedef int(*grpc_compression_algorithm_name_type)(grpc_compression_algorithm algorithm, char **name);
137
+ typedef int(*grpc_compression_algorithm_name_type)(grpc_compression_algorithm algorithm, const char **name);
168
138
  extern grpc_compression_algorithm_name_type grpc_compression_algorithm_name_import;
169
139
  #define grpc_compression_algorithm_name grpc_compression_algorithm_name_import
140
+ typedef int(*grpc_stream_compression_algorithm_name_type)(grpc_stream_compression_algorithm algorithm, const char **name);
141
+ extern grpc_stream_compression_algorithm_name_type grpc_stream_compression_algorithm_name_import;
142
+ #define grpc_stream_compression_algorithm_name grpc_stream_compression_algorithm_name_import
170
143
  typedef grpc_compression_algorithm(*grpc_compression_algorithm_for_level_type)(grpc_compression_level level, uint32_t accepted_encodings);
171
144
  extern grpc_compression_algorithm_for_level_type grpc_compression_algorithm_for_level_import;
172
145
  #define grpc_compression_algorithm_for_level grpc_compression_algorithm_for_level_import
146
+ typedef grpc_stream_compression_algorithm(*grpc_stream_compression_algorithm_for_level_type)(grpc_stream_compression_level level, uint32_t accepted_stream_encodings);
147
+ extern grpc_stream_compression_algorithm_for_level_type grpc_stream_compression_algorithm_for_level_import;
148
+ #define grpc_stream_compression_algorithm_for_level grpc_stream_compression_algorithm_for_level_import
173
149
  typedef void(*grpc_compression_options_init_type)(grpc_compression_options *opts);
174
150
  extern grpc_compression_options_init_type grpc_compression_options_init_import;
175
151
  #define grpc_compression_options_init grpc_compression_options_init_import
@@ -182,6 +158,9 @@ extern grpc_compression_options_disable_algorithm_type grpc_compression_options_
182
158
  typedef int(*grpc_compression_options_is_algorithm_enabled_type)(const grpc_compression_options *opts, grpc_compression_algorithm algorithm);
183
159
  extern grpc_compression_options_is_algorithm_enabled_type grpc_compression_options_is_algorithm_enabled_import;
184
160
  #define grpc_compression_options_is_algorithm_enabled grpc_compression_options_is_algorithm_enabled_import
161
+ typedef int(*grpc_compression_options_is_stream_compression_algorithm_enabled_type)(const grpc_compression_options *opts, grpc_stream_compression_algorithm algorithm);
162
+ extern grpc_compression_options_is_stream_compression_algorithm_enabled_type grpc_compression_options_is_stream_compression_algorithm_enabled_import;
163
+ #define grpc_compression_options_is_stream_compression_algorithm_enabled grpc_compression_options_is_stream_compression_algorithm_enabled_import
185
164
  typedef void(*grpc_metadata_array_init_type)(grpc_metadata_array *array);
186
165
  extern grpc_metadata_array_init_type grpc_metadata_array_init_import;
187
166
  #define grpc_metadata_array_init grpc_metadata_array_init_import
@@ -233,13 +212,16 @@ extern grpc_completion_queue_shutdown_type grpc_completion_queue_shutdown_import
233
212
  typedef void(*grpc_completion_queue_destroy_type)(grpc_completion_queue *cq);
234
213
  extern grpc_completion_queue_destroy_type grpc_completion_queue_destroy_import;
235
214
  #define grpc_completion_queue_destroy grpc_completion_queue_destroy_import
236
- typedef grpc_alarm *(*grpc_alarm_create_type)(grpc_completion_queue *cq, gpr_timespec deadline, void *tag);
215
+ typedef grpc_alarm *(*grpc_alarm_create_type)(void *reserved);
237
216
  extern grpc_alarm_create_type grpc_alarm_create_import;
238
217
  #define grpc_alarm_create grpc_alarm_create_import
239
- typedef void(*grpc_alarm_cancel_type)(grpc_alarm *alarm);
218
+ typedef void(*grpc_alarm_set_type)(grpc_alarm *alarm, grpc_completion_queue *cq, gpr_timespec deadline, void *tag, void *reserved);
219
+ extern grpc_alarm_set_type grpc_alarm_set_import;
220
+ #define grpc_alarm_set grpc_alarm_set_import
221
+ typedef void(*grpc_alarm_cancel_type)(grpc_alarm *alarm, void *reserved);
240
222
  extern grpc_alarm_cancel_type grpc_alarm_cancel_import;
241
223
  #define grpc_alarm_cancel grpc_alarm_cancel_import
242
- typedef void(*grpc_alarm_destroy_type)(grpc_alarm *alarm);
224
+ typedef void(*grpc_alarm_destroy_type)(grpc_alarm *alarm, void *reserved);
243
225
  extern grpc_alarm_destroy_type grpc_alarm_destroy_import;
244
226
  #define grpc_alarm_destroy grpc_alarm_destroy_import
245
227
  typedef grpc_connectivity_state(*grpc_channel_check_connectivity_state_type)(grpc_channel *channel, int try_to_connect);
@@ -251,6 +233,9 @@ extern grpc_channel_num_external_connectivity_watchers_type grpc_channel_num_ext
251
233
  typedef void(*grpc_channel_watch_connectivity_state_type)(grpc_channel *channel, grpc_connectivity_state last_observed_state, gpr_timespec deadline, grpc_completion_queue *cq, void *tag);
252
234
  extern grpc_channel_watch_connectivity_state_type grpc_channel_watch_connectivity_state_import;
253
235
  #define grpc_channel_watch_connectivity_state grpc_channel_watch_connectivity_state_import
236
+ typedef int(*grpc_channel_support_connectivity_watcher_type)(grpc_channel *channel);
237
+ extern grpc_channel_support_connectivity_watcher_type grpc_channel_support_connectivity_watcher_import;
238
+ #define grpc_channel_support_connectivity_watcher grpc_channel_support_connectivity_watcher_import
254
239
  typedef grpc_call *(*grpc_channel_create_call_type)(grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask, grpc_completion_queue *completion_queue, grpc_slice method, const grpc_slice *host, gpr_timespec deadline, void *reserved);
255
240
  extern grpc_channel_create_call_type grpc_channel_create_call_import;
256
241
  #define grpc_channel_create_call grpc_channel_create_call_import
@@ -470,6 +455,36 @@ extern grpc_call_set_credentials_type grpc_call_set_credentials_import;
470
455
  typedef void(*grpc_server_credentials_set_auth_metadata_processor_type)(grpc_server_credentials *creds, grpc_auth_metadata_processor processor);
471
456
  extern grpc_server_credentials_set_auth_metadata_processor_type grpc_server_credentials_set_auth_metadata_processor_import;
472
457
  #define grpc_server_credentials_set_auth_metadata_processor grpc_server_credentials_set_auth_metadata_processor_import
458
+ typedef grpc_byte_buffer *(*grpc_raw_byte_buffer_create_type)(grpc_slice *slices, size_t nslices);
459
+ extern grpc_raw_byte_buffer_create_type grpc_raw_byte_buffer_create_import;
460
+ #define grpc_raw_byte_buffer_create grpc_raw_byte_buffer_create_import
461
+ typedef grpc_byte_buffer *(*grpc_raw_compressed_byte_buffer_create_type)(grpc_slice *slices, size_t nslices, grpc_compression_algorithm compression);
462
+ extern grpc_raw_compressed_byte_buffer_create_type grpc_raw_compressed_byte_buffer_create_import;
463
+ #define grpc_raw_compressed_byte_buffer_create grpc_raw_compressed_byte_buffer_create_import
464
+ typedef grpc_byte_buffer *(*grpc_byte_buffer_copy_type)(grpc_byte_buffer *bb);
465
+ extern grpc_byte_buffer_copy_type grpc_byte_buffer_copy_import;
466
+ #define grpc_byte_buffer_copy grpc_byte_buffer_copy_import
467
+ typedef size_t(*grpc_byte_buffer_length_type)(grpc_byte_buffer *bb);
468
+ extern grpc_byte_buffer_length_type grpc_byte_buffer_length_import;
469
+ #define grpc_byte_buffer_length grpc_byte_buffer_length_import
470
+ typedef void(*grpc_byte_buffer_destroy_type)(grpc_byte_buffer *byte_buffer);
471
+ extern grpc_byte_buffer_destroy_type grpc_byte_buffer_destroy_import;
472
+ #define grpc_byte_buffer_destroy grpc_byte_buffer_destroy_import
473
+ typedef int(*grpc_byte_buffer_reader_init_type)(grpc_byte_buffer_reader *reader, grpc_byte_buffer *buffer);
474
+ extern grpc_byte_buffer_reader_init_type grpc_byte_buffer_reader_init_import;
475
+ #define grpc_byte_buffer_reader_init grpc_byte_buffer_reader_init_import
476
+ typedef void(*grpc_byte_buffer_reader_destroy_type)(grpc_byte_buffer_reader *reader);
477
+ extern grpc_byte_buffer_reader_destroy_type grpc_byte_buffer_reader_destroy_import;
478
+ #define grpc_byte_buffer_reader_destroy grpc_byte_buffer_reader_destroy_import
479
+ typedef int(*grpc_byte_buffer_reader_next_type)(grpc_byte_buffer_reader *reader, grpc_slice *slice);
480
+ extern grpc_byte_buffer_reader_next_type grpc_byte_buffer_reader_next_import;
481
+ #define grpc_byte_buffer_reader_next grpc_byte_buffer_reader_next_import
482
+ typedef grpc_slice(*grpc_byte_buffer_reader_readall_type)(grpc_byte_buffer_reader *reader);
483
+ extern grpc_byte_buffer_reader_readall_type grpc_byte_buffer_reader_readall_import;
484
+ #define grpc_byte_buffer_reader_readall grpc_byte_buffer_reader_readall_import
485
+ typedef grpc_byte_buffer *(*grpc_raw_byte_buffer_from_reader_type)(grpc_byte_buffer_reader *reader);
486
+ extern grpc_raw_byte_buffer_from_reader_type grpc_raw_byte_buffer_from_reader_import;
487
+ #define grpc_raw_byte_buffer_from_reader grpc_raw_byte_buffer_from_reader_import
473
488
  typedef grpc_slice(*grpc_slice_ref_type)(grpc_slice s);
474
489
  extern grpc_slice_ref_type grpc_slice_ref_import;
475
490
  #define grpc_slice_ref grpc_slice_ref_import
@@ -24,6 +24,7 @@ require_relative 'grpc/generic/active_call'
24
24
  require_relative 'grpc/generic/client_stub'
25
25
  require_relative 'grpc/generic/service'
26
26
  require_relative 'grpc/generic/rpc_server'
27
+ require_relative 'grpc/generic/interceptors'
27
28
 
28
29
  begin
29
30
  file = File.open(ssl_roots_path)
@@ -154,6 +154,15 @@ module GRPC
154
154
  Operation.new(self)
155
155
  end
156
156
 
157
+ ##
158
+ # Returns a restricted view of this ActiveCall for use in interceptors
159
+ #
160
+ # @return [InterceptableView]
161
+ #
162
+ def interceptable
163
+ InterceptableView.new(self)
164
+ end
165
+
157
166
  def receive_and_check_status
158
167
  batch_result = @call.run_batch(RECV_STATUS_ON_CLIENT => nil)
159
168
  set_input_stream_done
@@ -515,15 +524,27 @@ module GRPC
515
524
  # This does not mean that must necessarily be one. E.g, the replies
516
525
  # produced by gen_each_reply could ignore the received_msgs
517
526
  #
518
- # @param gen_each_reply [Proc] generates the BiDi stream replies
519
- def run_server_bidi(gen_each_reply)
520
- bd = BidiCall.new(@call,
521
- @marshal,
522
- @unmarshal,
523
- metadata_received: @metadata_received,
524
- req_view: MultiReqView.new(self))
525
-
526
- bd.run_on_server(gen_each_reply, proc { set_input_stream_done })
527
+ # @param mth [Proc] generates the BiDi stream replies
528
+ # @param interception_ctx [InterceptionContext]
529
+ #
530
+ def run_server_bidi(mth, interception_ctx)
531
+ view = multi_req_view
532
+ bidi_call = BidiCall.new(
533
+ @call,
534
+ @marshal,
535
+ @unmarshal,
536
+ metadata_received: @metadata_received,
537
+ req_view: view
538
+ )
539
+ requests = bidi_call.read_next_loop(proc { set_input_stream_done }, false)
540
+ interception_ctx.intercept!(
541
+ :bidi_streamer,
542
+ call: view,
543
+ method: mth,
544
+ requests: requests
545
+ ) do
546
+ bidi_call.run_on_server(mth, requests)
547
+ end
527
548
  end
528
549
 
529
550
  # Waits till an operation completes
@@ -645,5 +666,9 @@ module GRPC
645
666
  Operation = view_class(:cancel, :cancelled?, :deadline, :execute,
646
667
  :metadata, :status, :start_call, :wait, :write_flag,
647
668
  :write_flag=, :trailing_metadata)
669
+
670
+ # InterceptableView further limits access to an ActiveCall's methods
671
+ # for use in interceptors on the client, exposing only the deadline
672
+ InterceptableView = view_class(:deadline)
648
673
  end
649
674
  end
@@ -87,23 +87,32 @@ module GRPC
87
87
  # This does not mean that must necessarily be one. E.g, the replies
88
88
  # produced by gen_each_reply could ignore the received_msgs
89
89
  #
90
- # @param gen_each_reply [Proc] generates the BiDi stream replies.
91
- # @param set_input_steam_done [Proc] call back to call when
92
- # the reads have been completely read through.
93
- def run_on_server(gen_each_reply, set_input_stream_done)
90
+ # @param [Proc] gen_each_reply generates the BiDi stream replies.
91
+ # @param [Enumerable] requests The enumerable of requests to run
92
+ def run_on_server(gen_each_reply, requests)
93
+ replies = nil
94
+
94
95
  # Pass in the optional call object parameter if possible
95
96
  if gen_each_reply.arity == 1
96
- replys = gen_each_reply.call(
97
- read_loop(set_input_stream_done, is_client: false))
97
+ replies = gen_each_reply.call(requests)
98
98
  elsif gen_each_reply.arity == 2
99
- replys = gen_each_reply.call(
100
- read_loop(set_input_stream_done, is_client: false),
101
- @req_view)
99
+ replies = gen_each_reply.call(requests, @req_view)
102
100
  else
103
101
  fail 'Illegal arity of reply generator'
104
102
  end
105
103
 
106
- write_loop(replys, is_client: false)
104
+ write_loop(replies, is_client: false)
105
+ end
106
+
107
+ ##
108
+ # Read the next stream iteration
109
+ #
110
+ # @param [Proc] finalize_stream callback to call when the reads have been
111
+ # completely read through.
112
+ # @param [Boolean] is_client If this is a client or server request
113
+ #
114
+ def read_next_loop(finalize_stream, is_client = false)
115
+ read_loop(finalize_stream, is_client: is_client)
107
116
  end
108
117
 
109
118
  private
@@ -89,17 +89,23 @@ module GRPC
89
89
  # used within a gRPC server.
90
90
  # @param channel_args [Hash] the channel arguments. Note: this argument is
91
91
  # ignored if the channel_override argument is provided.
92
+ # @param interceptors [Array<GRPC::ClientInterceptor>] An array of
93
+ # GRPC::ClientInterceptor objects that will be used for
94
+ # intercepting calls before they are executed
95
+ # Interceptors are an EXPERIMENTAL API.
92
96
  def initialize(host, creds,
93
97
  channel_override: nil,
94
98
  timeout: nil,
95
99
  propagate_mask: nil,
96
- channel_args: {})
100
+ channel_args: {},
101
+ interceptors: [])
97
102
  @ch = ClientStub.setup_channel(channel_override, host, creds,
98
103
  channel_args)
99
104
  alt_host = channel_args[Core::Channel::SSL_TARGET]
100
105
  @host = alt_host.nil? ? host : alt_host
101
106
  @propagate_mask = propagate_mask
102
107
  @timeout = timeout.nil? ? DEFAULT_TIMEOUT : timeout
108
+ @interceptors = InterceptorRegistry.new(interceptors)
103
109
  end
104
110
 
105
111
  # request_response sends a request to a GRPC server, and returns the
@@ -149,16 +155,29 @@ module GRPC
149
155
  deadline: deadline,
150
156
  parent: parent,
151
157
  credentials: credentials)
152
- return c.request_response(req, metadata: metadata) unless return_op
153
-
154
- # return the operation view of the active_call; define #execute as a
155
- # new method for this instance that invokes #request_response.
156
- c.merge_metadata_to_send(metadata)
157
- op = c.operation
158
- op.define_singleton_method(:execute) do
159
- c.request_response(req, metadata: metadata)
158
+ interception_context = @interceptors.build_context
159
+ intercept_args = {
160
+ method: method,
161
+ request: req,
162
+ call: c.interceptable,
163
+ metadata: metadata
164
+ }
165
+ if return_op
166
+ # return the operation view of the active_call; define #execute as a
167
+ # new method for this instance that invokes #request_response.
168
+ c.merge_metadata_to_send(metadata)
169
+ op = c.operation
170
+ op.define_singleton_method(:execute) do
171
+ interception_context.intercept!(:request_response, intercept_args) do
172
+ c.request_response(req, metadata: metadata)
173
+ end
174
+ end
175
+ op
176
+ else
177
+ interception_context.intercept!(:request_response, intercept_args) do
178
+ c.request_response(req, metadata: metadata)
179
+ end
160
180
  end
161
- op
162
181
  end
163
182
 
164
183
  # client_streamer sends a stream of requests to a GRPC server, and
@@ -213,16 +232,29 @@ module GRPC
213
232
  deadline: deadline,
214
233
  parent: parent,
215
234
  credentials: credentials)
216
- return c.client_streamer(requests, metadata: metadata) unless return_op
217
-
218
- # return the operation view of the active_call; define #execute as a
219
- # new method for this instance that invokes #client_streamer.
220
- c.merge_metadata_to_send(metadata)
221
- op = c.operation
222
- op.define_singleton_method(:execute) do
223
- c.client_streamer(requests)
235
+ interception_context = @interceptors.build_context
236
+ intercept_args = {
237
+ method: method,
238
+ requests: requests,
239
+ call: c.interceptable,
240
+ metadata: metadata
241
+ }
242
+ if return_op
243
+ # return the operation view of the active_call; define #execute as a
244
+ # new method for this instance that invokes #client_streamer.
245
+ c.merge_metadata_to_send(metadata)
246
+ op = c.operation
247
+ op.define_singleton_method(:execute) do
248
+ interception_context.intercept!(:client_streamer, intercept_args) do
249
+ c.client_streamer(requests)
250
+ end
251
+ end
252
+ op
253
+ else
254
+ interception_context.intercept!(:client_streamer, intercept_args) do
255
+ c.client_streamer(requests, metadata: metadata)
256
+ end
224
257
  end
225
- op
226
258
  end
227
259
 
228
260
  # server_streamer sends one request to the GRPC server, which yields a
@@ -292,16 +324,29 @@ module GRPC
292
324
  deadline: deadline,
293
325
  parent: parent,
294
326
  credentials: credentials)
295
- return c.server_streamer(req, metadata: metadata, &blk) unless return_op
296
-
297
- # return the operation view of the active_call; define #execute
298
- # as a new method for this instance that invokes #server_streamer
299
- c.merge_metadata_to_send(metadata)
300
- op = c.operation
301
- op.define_singleton_method(:execute) do
302
- c.server_streamer(req, &blk)
327
+ interception_context = @interceptors.build_context
328
+ intercept_args = {
329
+ method: method,
330
+ request: req,
331
+ call: c.interceptable,
332
+ metadata: metadata
333
+ }
334
+ if return_op
335
+ # return the operation view of the active_call; define #execute
336
+ # as a new method for this instance that invokes #server_streamer
337
+ c.merge_metadata_to_send(metadata)
338
+ op = c.operation
339
+ op.define_singleton_method(:execute) do
340
+ interception_context.intercept!(:server_streamer, intercept_args) do
341
+ c.server_streamer(req, &blk)
342
+ end
343
+ end
344
+ op
345
+ else
346
+ interception_context.intercept!(:server_streamer, intercept_args) do
347
+ c.server_streamer(req, metadata: metadata, &blk)
348
+ end
303
349
  end
304
- op
305
350
  end
306
351
 
307
352
  # bidi_streamer sends a stream of requests to the GRPC server, and yields
@@ -405,17 +450,29 @@ module GRPC
405
450
  deadline: deadline,
406
451
  parent: parent,
407
452
  credentials: credentials)
408
- return c.bidi_streamer(requests, metadata: metadata,
409
- &blk) unless return_op
410
-
411
- # return the operation view of the active_call; define #execute
412
- # as a new method for this instance that invokes #bidi_streamer
413
- c.merge_metadata_to_send(metadata)
414
- op = c.operation
415
- op.define_singleton_method(:execute) do
416
- c.bidi_streamer(requests, &blk)
453
+ interception_context = @interceptors.build_context
454
+ intercept_args = {
455
+ method: method,
456
+ requests: requests,
457
+ call: c.interceptable,
458
+ metadata: metadata
459
+ }
460
+ if return_op
461
+ # return the operation view of the active_call; define #execute
462
+ # as a new method for this instance that invokes #bidi_streamer
463
+ c.merge_metadata_to_send(metadata)
464
+ op = c.operation
465
+ op.define_singleton_method(:execute) do
466
+ interception_context.intercept!(:bidi_streamer, intercept_args) do
467
+ c.bidi_streamer(requests, &blk)
468
+ end
469
+ end
470
+ op
471
+ else
472
+ interception_context.intercept!(:bidi_streamer, intercept_args) do
473
+ c.bidi_streamer(requests, metadata: metadata, &blk)
474
+ end
417
475
  end
418
- op
419
476
  end
420
477
 
421
478
  private