grpc 0.13.0.pre1.1-universal-darwin

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 (95) hide show
  1. checksums.yaml +7 -0
  2. data/etc/roots.pem +5114 -0
  3. data/grpc_c.32.ruby +0 -0
  4. data/grpc_c.64.ruby +0 -0
  5. data/src/ruby/bin/apis/google/protobuf/empty.rb +44 -0
  6. data/src/ruby/bin/apis/pubsub_demo.rb +256 -0
  7. data/src/ruby/bin/apis/tech/pubsub/proto/pubsub.rb +174 -0
  8. data/src/ruby/bin/apis/tech/pubsub/proto/pubsub_services.rb +103 -0
  9. data/src/ruby/bin/grpc_ruby_interop_client +33 -0
  10. data/src/ruby/bin/grpc_ruby_interop_server +33 -0
  11. data/src/ruby/bin/interop/interop_client.rb +51 -0
  12. data/src/ruby/bin/interop/interop_server.rb +50 -0
  13. data/src/ruby/bin/math.rb +32 -0
  14. data/src/ruby/bin/math_client.rb +147 -0
  15. data/src/ruby/bin/math_server.rb +206 -0
  16. data/src/ruby/bin/math_services.rb +27 -0
  17. data/src/ruby/bin/noproto_client.rb +108 -0
  18. data/src/ruby/bin/noproto_server.rb +112 -0
  19. data/src/ruby/ext/grpc/extconf.rb +129 -0
  20. data/src/ruby/ext/grpc/rb_byte_buffer.c +70 -0
  21. data/src/ruby/ext/grpc/rb_byte_buffer.h +47 -0
  22. data/src/ruby/ext/grpc/rb_call.c +908 -0
  23. data/src/ruby/ext/grpc/rb_call.h +66 -0
  24. data/src/ruby/ext/grpc/rb_call_credentials.c +319 -0
  25. data/src/ruby/ext/grpc/rb_call_credentials.h +46 -0
  26. data/src/ruby/ext/grpc/rb_channel.c +432 -0
  27. data/src/ruby/ext/grpc/rb_channel.h +47 -0
  28. data/src/ruby/ext/grpc/rb_channel_args.c +169 -0
  29. data/src/ruby/ext/grpc/rb_channel_args.h +53 -0
  30. data/src/ruby/ext/grpc/rb_channel_credentials.c +268 -0
  31. data/src/ruby/ext/grpc/rb_channel_credentials.h +47 -0
  32. data/src/ruby/ext/grpc/rb_completion_queue.c +183 -0
  33. data/src/ruby/ext/grpc/rb_completion_queue.h +55 -0
  34. data/src/ruby/ext/grpc/rb_event_thread.c +158 -0
  35. data/src/ruby/ext/grpc/rb_event_thread.h +37 -0
  36. data/src/ruby/ext/grpc/rb_grpc.c +336 -0
  37. data/src/ruby/ext/grpc/rb_grpc.h +85 -0
  38. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +560 -0
  39. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +843 -0
  40. data/src/ruby/ext/grpc/rb_loader.c +72 -0
  41. data/src/ruby/ext/grpc/rb_loader.h +40 -0
  42. data/src/ruby/ext/grpc/rb_server.c +400 -0
  43. data/src/ruby/ext/grpc/rb_server.h +47 -0
  44. data/src/ruby/ext/grpc/rb_server_credentials.c +284 -0
  45. data/src/ruby/ext/grpc/rb_server_credentials.h +47 -0
  46. data/src/ruby/lib/grpc.rb +44 -0
  47. data/src/ruby/lib/grpc/2.0/grpc_c.bundle +0 -0
  48. data/src/ruby/lib/grpc/2.1/grpc_c.bundle +0 -0
  49. data/src/ruby/lib/grpc/2.2/grpc_c.bundle +0 -0
  50. data/src/ruby/lib/grpc/2.3/grpc_c.bundle +0 -0
  51. data/src/ruby/lib/grpc/core/time_consts.rb +71 -0
  52. data/src/ruby/lib/grpc/errors.rb +62 -0
  53. data/src/ruby/lib/grpc/generic/active_call.rb +488 -0
  54. data/src/ruby/lib/grpc/generic/bidi_call.rb +218 -0
  55. data/src/ruby/lib/grpc/generic/client_stub.rb +471 -0
  56. data/src/ruby/lib/grpc/generic/rpc_desc.rb +147 -0
  57. data/src/ruby/lib/grpc/generic/rpc_server.rb +504 -0
  58. data/src/ruby/lib/grpc/generic/service.rb +234 -0
  59. data/src/ruby/lib/grpc/grpc.rb +34 -0
  60. data/src/ruby/lib/grpc/logconfig.rb +59 -0
  61. data/src/ruby/lib/grpc/notifier.rb +60 -0
  62. data/src/ruby/lib/grpc/version.rb +33 -0
  63. data/src/ruby/pb/README.md +42 -0
  64. data/src/ruby/pb/generate_proto_ruby.sh +51 -0
  65. data/src/ruby/pb/grpc/health/checker.rb +75 -0
  66. data/src/ruby/pb/grpc/health/v1alpha/health.rb +29 -0
  67. data/src/ruby/pb/grpc/health/v1alpha/health_services.rb +28 -0
  68. data/src/ruby/pb/test/client.rb +469 -0
  69. data/src/ruby/pb/test/proto/empty.rb +15 -0
  70. data/src/ruby/pb/test/proto/messages.rb +80 -0
  71. data/src/ruby/pb/test/proto/test.rb +14 -0
  72. data/src/ruby/pb/test/proto/test_services.rb +64 -0
  73. data/src/ruby/pb/test/server.rb +253 -0
  74. data/src/ruby/spec/call_credentials_spec.rb +57 -0
  75. data/src/ruby/spec/call_spec.rb +163 -0
  76. data/src/ruby/spec/channel_credentials_spec.rb +97 -0
  77. data/src/ruby/spec/channel_spec.rb +177 -0
  78. data/src/ruby/spec/client_server_spec.rb +475 -0
  79. data/src/ruby/spec/completion_queue_spec.rb +42 -0
  80. data/src/ruby/spec/generic/active_call_spec.rb +373 -0
  81. data/src/ruby/spec/generic/client_stub_spec.rb +476 -0
  82. data/src/ruby/spec/generic/rpc_desc_spec.rb +331 -0
  83. data/src/ruby/spec/generic/rpc_server_pool_spec.rb +138 -0
  84. data/src/ruby/spec/generic/rpc_server_spec.rb +576 -0
  85. data/src/ruby/spec/generic/service_spec.rb +345 -0
  86. data/src/ruby/spec/pb/health/checker_spec.rb +232 -0
  87. data/src/ruby/spec/server_credentials_spec.rb +94 -0
  88. data/src/ruby/spec/server_spec.rb +209 -0
  89. data/src/ruby/spec/spec_helper.rb +69 -0
  90. data/src/ruby/spec/testdata/README +1 -0
  91. data/src/ruby/spec/testdata/ca.pem +15 -0
  92. data/src/ruby/spec/testdata/server1.key +16 -0
  93. data/src/ruby/spec/testdata/server1.pem +16 -0
  94. data/src/ruby/spec/time_consts_spec.rb +89 -0
  95. metadata +319 -0
@@ -0,0 +1,47 @@
1
+ /*
2
+ *
3
+ * Copyright 2015, 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_RB_SERVER_H_
35
+ #define GRPC_RB_SERVER_H_
36
+
37
+ #include <ruby/ruby.h>
38
+
39
+ #include <grpc/grpc.h>
40
+
41
+ /* Initializes the Server class. */
42
+ void Init_grpc_server();
43
+
44
+ /* Gets the wrapped server from the ruby wrapper */
45
+ grpc_server* grpc_rb_get_wrapped_server(VALUE v);
46
+
47
+ #endif /* GRPC_RB_SERVER_H_ */
@@ -0,0 +1,284 @@
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
+ #include <ruby/ruby.h>
35
+ #include "rb_grpc_imports.generated.h"
36
+ #include "rb_server_credentials.h"
37
+
38
+ #include <ruby/ruby.h>
39
+
40
+ #include <grpc/grpc.h>
41
+ #include <grpc/grpc_security.h>
42
+
43
+ #include "rb_grpc.h"
44
+
45
+ /* grpc_rb_cServerCredentials is the ruby class that proxies
46
+ grpc_server_credentials. */
47
+ static VALUE grpc_rb_cServerCredentials = Qnil;
48
+
49
+ /* grpc_rb_server_credentials wraps a grpc_server_credentials. It provides a
50
+ peer ruby object, 'mark' to minimize copying when a server credential is
51
+ created from ruby. */
52
+ typedef struct grpc_rb_server_credentials {
53
+ /* Holder of ruby objects involved in constructing the server credentials */
54
+ VALUE mark;
55
+ /* The actual server credentials */
56
+ grpc_server_credentials *wrapped;
57
+ } grpc_rb_server_credentials;
58
+
59
+ /* Destroys the server credentials instances. */
60
+ static void grpc_rb_server_credentials_free(void *p) {
61
+ grpc_rb_server_credentials *wrapper = NULL;
62
+ if (p == NULL) {
63
+ return;
64
+ };
65
+ wrapper = (grpc_rb_server_credentials *)p;
66
+
67
+ /* Delete the wrapped object if the mark object is Qnil, which indicates that
68
+ no other object is the actual owner. */
69
+ if (wrapper->wrapped != NULL && wrapper->mark == Qnil) {
70
+ grpc_server_credentials_release(wrapper->wrapped);
71
+ wrapper->wrapped = NULL;
72
+ }
73
+
74
+ xfree(p);
75
+ }
76
+
77
+ /* Protects the mark object from GC */
78
+ static void grpc_rb_server_credentials_mark(void *p) {
79
+ grpc_rb_server_credentials *wrapper = NULL;
80
+ if (p == NULL) {
81
+ return;
82
+ }
83
+ wrapper = (grpc_rb_server_credentials *)p;
84
+
85
+ /* If it's not already cleaned up, mark the mark object */
86
+ if (wrapper->mark != Qnil) {
87
+ rb_gc_mark(wrapper->mark);
88
+ }
89
+ }
90
+
91
+ static const rb_data_type_t grpc_rb_server_credentials_data_type = {
92
+ "grpc_server_credentials",
93
+ {grpc_rb_server_credentials_mark, grpc_rb_server_credentials_free,
94
+ GRPC_RB_MEMSIZE_UNAVAILABLE, {NULL, NULL}},
95
+ NULL, NULL,
96
+ #ifdef RUBY_TYPED_FREE_IMMEDIATELY
97
+ RUBY_TYPED_FREE_IMMEDIATELY
98
+ #endif
99
+ };
100
+
101
+ /* Allocates ServerCredential instances.
102
+
103
+ Provides safe initial defaults for the instance fields. */
104
+ static VALUE grpc_rb_server_credentials_alloc(VALUE cls) {
105
+ grpc_rb_server_credentials *wrapper = ALLOC(grpc_rb_server_credentials);
106
+ wrapper->wrapped = NULL;
107
+ wrapper->mark = Qnil;
108
+ return TypedData_Wrap_Struct(cls, &grpc_rb_server_credentials_data_type,
109
+ wrapper);
110
+ }
111
+
112
+ /* Clones ServerCredentials instances.
113
+
114
+ Gives ServerCredentials a consistent implementation of Ruby's object copy/dup
115
+ protocol. */
116
+ static VALUE grpc_rb_server_credentials_init_copy(VALUE copy, VALUE orig) {
117
+ grpc_rb_server_credentials *orig_ch = NULL;
118
+ grpc_rb_server_credentials *copy_ch = NULL;
119
+
120
+ if (copy == orig) {
121
+ return copy;
122
+ }
123
+
124
+ /* Raise an error if orig is not a server_credentials object or a subclass. */
125
+ if (TYPE(orig) != T_DATA ||
126
+ RDATA(orig)->dfree != (RUBY_DATA_FUNC)grpc_rb_server_credentials_free) {
127
+ rb_raise(rb_eTypeError, "not a %s",
128
+ rb_obj_classname(grpc_rb_cServerCredentials));
129
+ }
130
+
131
+ TypedData_Get_Struct(orig, grpc_rb_server_credentials,
132
+ &grpc_rb_server_credentials_data_type, orig_ch);
133
+ TypedData_Get_Struct(copy, grpc_rb_server_credentials,
134
+ &grpc_rb_server_credentials_data_type, copy_ch);
135
+
136
+ /* use ruby's MEMCPY to make a byte-for-byte copy of the server_credentials
137
+ wrapper object. */
138
+ MEMCPY(copy_ch, orig_ch, grpc_rb_server_credentials, 1);
139
+ return copy;
140
+ }
141
+
142
+ /* The attribute used on the mark object to preserve the pem_root_certs. */
143
+ static ID id_pem_root_certs;
144
+
145
+ /* The attribute used on the mark object to preserve the pem_key_certs */
146
+ static ID id_pem_key_certs;
147
+
148
+ /* The key used to access the pem cert in a key_cert pair hash */
149
+ static VALUE sym_cert_chain;
150
+
151
+ /* The key used to access the pem private key in a key_cert pair hash */
152
+ static VALUE sym_private_key;
153
+
154
+ /*
155
+ call-seq:
156
+ creds = ServerCredentials.new(nil,
157
+ [{private_key: <pem_private_key1>,
158
+ {cert_chain: <pem_cert_chain1>}],
159
+ force_client_auth)
160
+ creds = ServerCredentials.new(pem_root_certs,
161
+ [{private_key: <pem_private_key1>,
162
+ {cert_chain: <pem_cert_chain1>}],
163
+ force_client_auth)
164
+
165
+ pem_root_certs: (optional) PEM encoding of the server root certificate
166
+ pem_private_key: (required) PEM encoding of the server's private keys
167
+ force_client_auth: indicatees
168
+
169
+ Initializes ServerCredential instances. */
170
+ static VALUE grpc_rb_server_credentials_init(VALUE self, VALUE pem_root_certs,
171
+ VALUE pem_key_certs,
172
+ VALUE force_client_auth) {
173
+ grpc_rb_server_credentials *wrapper = NULL;
174
+ grpc_server_credentials *creds = NULL;
175
+ grpc_ssl_pem_key_cert_pair *key_cert_pairs = NULL;
176
+ VALUE cert = Qnil;
177
+ VALUE key = Qnil;
178
+ VALUE key_cert = Qnil;
179
+ int auth_client = 0;
180
+ long num_key_certs = 0;
181
+ int i;
182
+
183
+ if (NIL_P(force_client_auth) ||
184
+ !(force_client_auth == Qfalse || force_client_auth == Qtrue)) {
185
+ rb_raise(rb_eTypeError,
186
+ "bad force_client_auth: got:<%s> want: <True|False|nil>",
187
+ rb_obj_classname(force_client_auth));
188
+ return Qnil;
189
+ }
190
+ if (NIL_P(pem_key_certs) || TYPE(pem_key_certs) != T_ARRAY) {
191
+ rb_raise(rb_eTypeError, "bad pem_key_certs: got:<%s> want: <Array>",
192
+ rb_obj_classname(pem_key_certs));
193
+ return Qnil;
194
+ }
195
+ num_key_certs = RARRAY_LEN(pem_key_certs);
196
+ if (num_key_certs == 0) {
197
+ rb_raise(rb_eTypeError, "bad pem_key_certs: it had no elements");
198
+ return Qnil;
199
+ }
200
+ for (i = 0; i < num_key_certs; i++) {
201
+ key_cert = rb_ary_entry(pem_key_certs, i);
202
+ if (key_cert == Qnil) {
203
+ rb_raise(rb_eTypeError,
204
+ "could not create a server credential: nil key_cert");
205
+ return Qnil;
206
+ } else if (TYPE(key_cert) != T_HASH) {
207
+ rb_raise(rb_eTypeError,
208
+ "could not create a server credential: want <Hash>, got <%s>",
209
+ rb_obj_classname(key_cert));
210
+ return Qnil;
211
+ } else if (rb_hash_aref(key_cert, sym_private_key) == Qnil) {
212
+ rb_raise(rb_eTypeError,
213
+ "could not create a server credential: want nil private key");
214
+ return Qnil;
215
+ } else if (rb_hash_aref(key_cert, sym_cert_chain) == Qnil) {
216
+ rb_raise(rb_eTypeError,
217
+ "could not create a server credential: want nil cert chain");
218
+ return Qnil;
219
+ }
220
+ }
221
+
222
+ auth_client = TYPE(force_client_auth) == T_TRUE;
223
+ key_cert_pairs = ALLOC_N(grpc_ssl_pem_key_cert_pair, num_key_certs);
224
+ for (i = 0; i < num_key_certs; i++) {
225
+ key_cert = rb_ary_entry(pem_key_certs, i);
226
+ key = rb_hash_aref(key_cert, sym_private_key);
227
+ cert = rb_hash_aref(key_cert, sym_cert_chain);
228
+ key_cert_pairs[i].private_key = RSTRING_PTR(key);
229
+ key_cert_pairs[i].cert_chain = RSTRING_PTR(cert);
230
+ }
231
+
232
+ TypedData_Get_Struct(self, grpc_rb_server_credentials,
233
+ &grpc_rb_server_credentials_data_type, wrapper);
234
+
235
+ if (pem_root_certs == Qnil) {
236
+ creds = grpc_ssl_server_credentials_create(NULL, key_cert_pairs,
237
+ num_key_certs,
238
+ auth_client, NULL);
239
+ } else {
240
+ creds = grpc_ssl_server_credentials_create(RSTRING_PTR(pem_root_certs),
241
+ key_cert_pairs, num_key_certs,
242
+ auth_client, NULL);
243
+ }
244
+ xfree(key_cert_pairs);
245
+ if (creds == NULL) {
246
+ rb_raise(rb_eRuntimeError, "could not create a credentials, not sure why");
247
+ return Qnil;
248
+ }
249
+ wrapper->wrapped = creds;
250
+
251
+ /* Add the input objects as hidden fields to preserve them. */
252
+ rb_ivar_set(self, id_pem_key_certs, pem_key_certs);
253
+ rb_ivar_set(self, id_pem_root_certs, pem_root_certs);
254
+
255
+ return self;
256
+ }
257
+
258
+ void Init_grpc_server_credentials() {
259
+ grpc_rb_cServerCredentials =
260
+ rb_define_class_under(grpc_rb_mGrpcCore, "ServerCredentials", rb_cObject);
261
+
262
+ /* Allocates an object managed by the ruby runtime */
263
+ rb_define_alloc_func(grpc_rb_cServerCredentials,
264
+ grpc_rb_server_credentials_alloc);
265
+
266
+ /* Provides a ruby constructor and support for dup/clone. */
267
+ rb_define_method(grpc_rb_cServerCredentials, "initialize",
268
+ grpc_rb_server_credentials_init, 3);
269
+ rb_define_method(grpc_rb_cServerCredentials, "initialize_copy",
270
+ grpc_rb_server_credentials_init_copy, 1);
271
+
272
+ id_pem_key_certs = rb_intern("__pem_key_certs");
273
+ id_pem_root_certs = rb_intern("__pem_root_certs");
274
+ sym_private_key = ID2SYM(rb_intern("private_key"));
275
+ sym_cert_chain = ID2SYM(rb_intern("cert_chain"));
276
+ }
277
+
278
+ /* Gets the wrapped grpc_server_credentials from the ruby wrapper */
279
+ grpc_server_credentials *grpc_rb_get_wrapped_server_credentials(VALUE v) {
280
+ grpc_rb_server_credentials *wrapper = NULL;
281
+ TypedData_Get_Struct(v, grpc_rb_server_credentials,
282
+ &grpc_rb_server_credentials_data_type, wrapper);
283
+ return wrapper->wrapped;
284
+ }
@@ -0,0 +1,47 @@
1
+ /*
2
+ *
3
+ * Copyright 2015, 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_RB_SERVER_CREDENTIALS_H_
35
+ #define GRPC_RB_SERVER_CREDENTIALS_H_
36
+
37
+ #include <ruby/ruby.h>
38
+
39
+ #include <grpc/grpc_security.h>
40
+
41
+ /* Initializes the ruby ServerCredentials class. */
42
+ void Init_grpc_server_credentials();
43
+
44
+ /* Gets the wrapped server_credentials from the ruby wrapper */
45
+ grpc_server_credentials* grpc_rb_get_wrapped_server_credentials(VALUE v);
46
+
47
+ #endif /* GRPC_RB_SERVER_CREDENTIALS_H_ */
@@ -0,0 +1,44 @@
1
+ # Copyright 2015-2016, Google Inc.
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are
6
+ # met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+ # * Redistributions in binary form must reproduce the above
11
+ # copyright notice, this list of conditions and the following disclaimer
12
+ # in the documentation and/or other materials provided with the
13
+ # distribution.
14
+ # * Neither the name of Google Inc. nor the names of its
15
+ # contributors may be used to endorse or promote products derived from
16
+ # this software without specific prior written permission.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ ssl_roots_path = File.expand_path('../../../../etc/roots.pem', __FILE__)
31
+ unless ENV['GRPC_DEFAULT_SSL_ROOTS_FILE_PATH']
32
+ ENV['GRPC_DEFAULT_SSL_ROOTS_FILE_PATH'] = ssl_roots_path
33
+ end
34
+
35
+ require 'grpc/errors'
36
+ require 'grpc/grpc'
37
+ require 'grpc/logconfig'
38
+ require 'grpc/notifier'
39
+ require 'grpc/version'
40
+ require 'grpc/core/time_consts'
41
+ require 'grpc/generic/active_call'
42
+ require 'grpc/generic/client_stub'
43
+ require 'grpc/generic/service'
44
+ require 'grpc/generic/rpc_server'
@@ -0,0 +1,71 @@
1
+ # Copyright 2015, Google Inc.
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are
6
+ # met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+ # * Redistributions in binary form must reproduce the above
11
+ # copyright notice, this list of conditions and the following disclaimer
12
+ # in the documentation and/or other materials provided with the
13
+ # distribution.
14
+ # * Neither the name of Google Inc. nor the names of its
15
+ # contributors may be used to endorse or promote products derived from
16
+ # this software without specific prior written permission.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ require 'grpc'
31
+
32
+ # GRPC contains the General RPC module.
33
+ module GRPC
34
+ module Core
35
+ # TimeConsts is a module from the C extension.
36
+ #
37
+ # Here it's re-opened to add a utility func.
38
+ module TimeConsts
39
+ # Converts a time delta to an absolute deadline.
40
+ #
41
+ # Assumes timeish is a relative time, and converts its to an absolute,
42
+ # with following exceptions:
43
+ #
44
+ # * if timish is one of the TimeConsts.TimeSpec constants the value is
45
+ # preserved.
46
+ # * timish < 0 => TimeConsts.INFINITE_FUTURE
47
+ # * timish == 0 => TimeConsts.ZERO
48
+ #
49
+ # @param timeish [Number|TimeSpec]
50
+ # @return timeish [Number|TimeSpec]
51
+ def from_relative_time(timeish)
52
+ if timeish.is_a? TimeSpec
53
+ timeish
54
+ elsif timeish.nil?
55
+ TimeConsts::ZERO
56
+ elsif !timeish.is_a? Numeric
57
+ fail(TypeError,
58
+ "Cannot make an absolute deadline from #{timeish.inspect}")
59
+ elsif timeish < 0
60
+ TimeConsts::INFINITE_FUTURE
61
+ elsif timeish.zero?
62
+ TimeConsts::ZERO
63
+ else
64
+ Time.now + timeish
65
+ end
66
+ end
67
+
68
+ module_function :from_relative_time
69
+ end
70
+ end
71
+ end