grpc 0.6.0 → 0.6.1

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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/.rubocop_todo.yml +12 -20
  4. data/CHANGELOG.md +11 -0
  5. data/Rakefile +1 -0
  6. data/bin/apis/pubsub_demo.rb +3 -6
  7. data/bin/interop/interop_client.rb +43 -3
  8. data/bin/interop/interop_server.rb +1 -1
  9. data/bin/math_server.rb +1 -1
  10. data/bin/noproto_server.rb +1 -1
  11. data/ext/grpc/rb_byte_buffer.c +15 -189
  12. data/ext/grpc/rb_byte_buffer.h +4 -12
  13. data/ext/grpc/rb_call.c +514 -307
  14. data/ext/grpc/rb_call.h +4 -4
  15. data/ext/grpc/rb_channel.c +58 -34
  16. data/ext/grpc/rb_channel.h +0 -3
  17. data/ext/grpc/rb_channel_args.c +13 -4
  18. data/ext/grpc/rb_completion_queue.c +50 -23
  19. data/ext/grpc/rb_completion_queue.h +7 -3
  20. data/ext/grpc/rb_credentials.c +40 -28
  21. data/ext/grpc/rb_credentials.h +0 -4
  22. data/ext/grpc/rb_grpc.c +86 -67
  23. data/ext/grpc/rb_grpc.h +20 -10
  24. data/ext/grpc/rb_server.c +119 -26
  25. data/ext/grpc/rb_server.h +0 -4
  26. data/ext/grpc/rb_server_credentials.c +29 -16
  27. data/ext/grpc/rb_server_credentials.h +0 -4
  28. data/grpc.gemspec +11 -8
  29. data/lib/grpc.rb +1 -1
  30. data/lib/grpc/errors.rb +8 -7
  31. data/lib/grpc/generic/active_call.rb +104 -171
  32. data/lib/grpc/generic/bidi_call.rb +32 -60
  33. data/lib/grpc/generic/client_stub.rb +42 -31
  34. data/lib/grpc/generic/rpc_desc.rb +7 -12
  35. data/lib/grpc/generic/rpc_server.rb +253 -170
  36. data/lib/grpc/{core/event.rb → notifier.rb} +25 -9
  37. data/lib/grpc/version.rb +1 -1
  38. data/spec/call_spec.rb +23 -40
  39. data/spec/channel_spec.rb +11 -20
  40. data/spec/client_server_spec.rb +193 -175
  41. data/spec/credentials_spec.rb +2 -2
  42. data/spec/generic/active_call_spec.rb +59 -85
  43. data/spec/generic/client_stub_spec.rb +46 -64
  44. data/spec/generic/rpc_desc_spec.rb +50 -80
  45. data/spec/generic/rpc_server_pool_spec.rb +2 -3
  46. data/spec/generic/rpc_server_spec.rb +158 -29
  47. data/spec/server_spec.rb +1 -1
  48. data/spec/spec_helper.rb +8 -4
  49. metadata +27 -37
  50. data/ext/grpc/rb_event.c +0 -361
  51. data/ext/grpc/rb_event.h +0 -53
  52. data/ext/grpc/rb_metadata.c +0 -215
  53. data/ext/grpc/rb_metadata.h +0 -53
  54. data/spec/alloc_spec.rb +0 -44
  55. data/spec/byte_buffer_spec.rb +0 -67
  56. data/spec/event_spec.rb +0 -53
  57. data/spec/metadata_spec.rb +0 -64
@@ -1,53 +0,0 @@
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_EVENT_H_
35
- #define GRPC_RB_EVENT_H_
36
-
37
- #include <ruby.h>
38
- #include <grpc/grpc.h>
39
-
40
- /* rb_cEvent is the Event class whose instances proxy grpc_event. */
41
- extern VALUE rb_cEvent;
42
-
43
- /* rb_cEventError is the ruby class that acts the exception thrown during rpc
44
- event processing. */
45
- extern VALUE rb_eEventError;
46
-
47
- /* Used to create new ruby event objects */
48
- VALUE grpc_rb_new_event(grpc_event *ev);
49
-
50
- /* Initializes the Event and EventError classes. */
51
- void Init_grpc_event();
52
-
53
- #endif /* GRPC_RB_EVENT_H_ */
@@ -1,215 +0,0 @@
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
- #include "rb_metadata.h"
35
-
36
- #include <ruby.h>
37
- #include <string.h>
38
-
39
- #include <grpc/grpc.h>
40
- #include "rb_grpc.h"
41
-
42
- /* grpc_rb_metadata wraps a grpc_metadata. It provides a peer ruby object,
43
- * 'mark' to minimize copying when a metadata is created from ruby. */
44
- typedef struct grpc_rb_metadata {
45
- /* Holder of ruby objects involved in constructing the metadata */
46
- VALUE mark;
47
- /* The actual metadata */
48
- grpc_metadata *wrapped;
49
- } grpc_rb_metadata;
50
-
51
- /* Destroys Metadata instances. */
52
- static void grpc_rb_metadata_free(void *p) {
53
- if (p == NULL) {
54
- return;
55
- };
56
-
57
- /* Because metadata is only created during a call to grpc_call_add_metadata,
58
- * and the call takes ownership of the metadata, this does not free the
59
- * wrapped struct, only the wrapper */
60
- xfree(p);
61
- }
62
-
63
- /* Protects the mark object from GC */
64
- static void grpc_rb_metadata_mark(void *p) {
65
- grpc_rb_metadata *md = NULL;
66
- if (p == NULL) {
67
- return;
68
- }
69
-
70
- md = (grpc_rb_metadata *)p;
71
- /* If it's not already cleaned up, mark the mark object */
72
- if (md->mark != Qnil && BUILTIN_TYPE(md->mark) != T_NONE) {
73
- rb_gc_mark(md->mark);
74
- }
75
- }
76
-
77
- /* Allocates Metadata instances.
78
-
79
- Provides safe default values for the Metadata fields. */
80
- static VALUE grpc_rb_metadata_alloc(VALUE cls) {
81
- grpc_rb_metadata *wrapper = ALLOC(grpc_rb_metadata);
82
- wrapper->wrapped = NULL;
83
- wrapper->mark = Qnil;
84
- return Data_Wrap_Struct(cls, grpc_rb_metadata_mark, grpc_rb_metadata_free,
85
- wrapper);
86
- }
87
-
88
- /* id_key and id_value are the names of the hidden ivars that preserve the
89
- * original byte_buffer source string */
90
- static ID id_key;
91
- static ID id_value;
92
-
93
- /* Initializes Metadata instances. */
94
- static VALUE grpc_rb_metadata_init(VALUE self, VALUE key, VALUE value) {
95
- grpc_rb_metadata *wrapper = NULL;
96
- grpc_metadata *md = ALLOC(grpc_metadata);
97
-
98
- /* Use direct pointers to the strings wrapped by the ruby object to avoid
99
- * copying */
100
- Data_Get_Struct(self, grpc_rb_metadata, wrapper);
101
- wrapper->wrapped = md;
102
- if (TYPE(key) == T_SYMBOL) {
103
- md->key = (char *)rb_id2name(SYM2ID(key));
104
- } else { /* StringValueCStr does all other type exclusions for us */
105
- md->key = StringValueCStr(key);
106
- }
107
- md->value = RSTRING_PTR(value);
108
- md->value_length = RSTRING_LEN(value);
109
-
110
- /* Save references to the original values on the mark object so that the
111
- * pointers used there are valid for the lifetime of the object. */
112
- wrapper->mark = rb_class_new_instance(0, NULL, rb_cObject);
113
- rb_ivar_set(wrapper->mark, id_key, key);
114
- rb_ivar_set(wrapper->mark, id_value, value);
115
-
116
- return self;
117
- }
118
-
119
- /* Clones Metadata instances.
120
-
121
- Gives Metadata a consistent implementation of Ruby's object copy/dup
122
- protocol. */
123
- static VALUE grpc_rb_metadata_init_copy(VALUE copy, VALUE orig) {
124
- grpc_rb_metadata *orig_md = NULL;
125
- grpc_rb_metadata *copy_md = NULL;
126
-
127
- if (copy == orig) {
128
- return copy;
129
- }
130
-
131
- /* Raise an error if orig is not a metadata object or a subclass. */
132
- if (TYPE(orig) != T_DATA ||
133
- RDATA(orig)->dfree != (RUBY_DATA_FUNC)grpc_rb_metadata_free) {
134
- rb_raise(rb_eTypeError, "not a %s", rb_obj_classname(rb_cMetadata));
135
- }
136
-
137
- Data_Get_Struct(orig, grpc_rb_metadata, orig_md);
138
- Data_Get_Struct(copy, grpc_rb_metadata, copy_md);
139
-
140
- /* use ruby's MEMCPY to make a byte-for-byte copy of the metadata wrapper
141
- * object. */
142
- MEMCPY(copy_md, orig_md, grpc_rb_metadata, 1);
143
- return copy;
144
- }
145
-
146
- /* Gets the key from a metadata instance. */
147
- static VALUE grpc_rb_metadata_key(VALUE self) {
148
- VALUE key = Qnil;
149
- grpc_rb_metadata *wrapper = NULL;
150
- grpc_metadata *md = NULL;
151
-
152
- Data_Get_Struct(self, grpc_rb_metadata, wrapper);
153
- if (wrapper->mark != Qnil) {
154
- key = rb_ivar_get(wrapper->mark, id_key);
155
- if (key != Qnil) {
156
- return key;
157
- }
158
- }
159
-
160
- md = wrapper->wrapped;
161
- if (md == NULL || md->key == NULL) {
162
- return Qnil;
163
- }
164
- return rb_str_new2(md->key);
165
- }
166
-
167
- /* Gets the value from a metadata instance. */
168
- static VALUE grpc_rb_metadata_value(VALUE self) {
169
- VALUE val = Qnil;
170
- grpc_rb_metadata *wrapper = NULL;
171
- grpc_metadata *md = NULL;
172
-
173
- Data_Get_Struct(self, grpc_rb_metadata, wrapper);
174
- if (wrapper->mark != Qnil) {
175
- val = rb_ivar_get(wrapper->mark, id_value);
176
- if (val != Qnil) {
177
- return val;
178
- }
179
- }
180
-
181
- md = wrapper->wrapped;
182
- if (md == NULL || md->value == NULL) {
183
- return Qnil;
184
- }
185
- return rb_str_new2(md->value);
186
- }
187
-
188
- /* rb_cMetadata is the Metadata class whose instances proxy grpc_metadata. */
189
- VALUE rb_cMetadata = Qnil;
190
- void Init_grpc_metadata() {
191
- rb_cMetadata =
192
- rb_define_class_under(rb_mGrpcCore, "Metadata", rb_cObject);
193
-
194
- /* Allocates an object managed by the ruby runtime */
195
- rb_define_alloc_func(rb_cMetadata, grpc_rb_metadata_alloc);
196
-
197
- /* Provides a ruby constructor and support for dup/clone. */
198
- rb_define_method(rb_cMetadata, "initialize", grpc_rb_metadata_init, 2);
199
- rb_define_method(rb_cMetadata, "initialize_copy", grpc_rb_metadata_init_copy,
200
- 1);
201
-
202
- /* Provides accessors for the code and details. */
203
- rb_define_method(rb_cMetadata, "key", grpc_rb_metadata_key, 0);
204
- rb_define_method(rb_cMetadata, "value", grpc_rb_metadata_value, 0);
205
-
206
- id_key = rb_intern("__key");
207
- id_value = rb_intern("__value");
208
- }
209
-
210
- /* Gets the wrapped metadata from the ruby wrapper */
211
- grpc_metadata *grpc_rb_get_wrapped_metadata(VALUE v) {
212
- grpc_rb_metadata *wrapper = NULL;
213
- Data_Get_Struct(v, grpc_rb_metadata, wrapper);
214
- return wrapper->wrapped;
215
- }
@@ -1,53 +0,0 @@
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_METADATA_H_
35
- #define GRPC_RB_METADATA_H_
36
-
37
- #include <grpc/grpc.h>
38
- #include <ruby.h>
39
-
40
- /* rb_cMetadata is the Metadata class whose instances proxy grpc_metadata. */
41
- extern VALUE rb_cMetadata;
42
-
43
- /* grpc_rb_metadata_create_with_mark creates a grpc_rb_metadata with a ruby mark
44
- * object that will be kept alive while the metadata is alive. */
45
- extern VALUE grpc_rb_metadata_create_with_mark(VALUE mark, grpc_metadata* md);
46
-
47
- /* Gets the wrapped metadata from the ruby wrapper */
48
- grpc_metadata* grpc_rb_get_wrapped_metadata(VALUE v);
49
-
50
- /* Initializes the Metadata class. */
51
- void Init_grpc_metadata();
52
-
53
- #endif /* GRPC_RB_METADATA_H_ */
@@ -1,44 +0,0 @@
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
- describe 'Wrapped classes where .new cannot create an instance' do
33
- describe GRPC::Core::Event do
34
- it 'should fail .new fail with a runtime error' do
35
- expect { GRPC::Core::Event.new }.to raise_error(TypeError)
36
- end
37
- end
38
-
39
- describe GRPC::Core::Call do
40
- it 'should fail .new fail with a runtime error' do
41
- expect { GRPC::Core::Event.new }.to raise_error(TypeError)
42
- end
43
- end
44
- end
@@ -1,67 +0,0 @@
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
- describe GRPC::Core::ByteBuffer do
33
- describe '#new' do
34
- it 'is constructed from a string' do
35
- expect { GRPC::Core::ByteBuffer.new('#new') }.not_to raise_error
36
- end
37
-
38
- it 'can be constructed from the empty string' do
39
- expect { GRPC::Core::ByteBuffer.new('') }.not_to raise_error
40
- end
41
-
42
- it 'cannot be constructed from nil' do
43
- expect { GRPC::Core::ByteBuffer.new(nil) }.to raise_error TypeError
44
- end
45
-
46
- it 'cannot be constructed from non-strings' do
47
- [1, Object.new, :a_symbol].each do |x|
48
- expect { GRPC::Core::ByteBuffer.new(x) }.to raise_error TypeError
49
- end
50
- end
51
- end
52
-
53
- describe '#to_s' do
54
- it 'is the string value the ByteBuffer was constructed with' do
55
- expect(GRPC::Core::ByteBuffer.new('#to_s').to_s).to eq('#to_s')
56
- end
57
- end
58
-
59
- describe '#dup' do
60
- it 'makes an instance whose #to_s is the original string value' do
61
- bb = GRPC::Core::ByteBuffer.new('#dup')
62
- a_copy = bb.dup
63
- expect(a_copy.to_s).to eq('#dup')
64
- expect(a_copy.dup.to_s).to eq('#dup')
65
- end
66
- end
67
- end
@@ -1,53 +0,0 @@
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
- describe GRPC::Core::CompletionType do
33
- before(:each) do
34
- @known_types = {
35
- QUEUE_SHUTDOWN: 0,
36
- OP_COMPLETE: 1,
37
- READ: 2,
38
- WRITE_ACCEPTED: 3,
39
- FINISH_ACCEPTED: 4,
40
- CLIENT_METADATA_READ: 5,
41
- FINISHED: 6,
42
- SERVER_RPC_NEW: 7,
43
- SERVER_SHUTDOWN: 8,
44
- RESERVED: 9
45
- }
46
- end
47
-
48
- it 'should have all the known types' do
49
- mod = GRPC::Core::CompletionType
50
- blk = proc { Hash[mod.constants.collect { |c| [c, mod.const_get(c)] }] }
51
- expect(blk.call).to eq(@known_types)
52
- end
53
- end