protobuffy 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/.travis.yml +12 -0
  4. data/.yardopts +5 -0
  5. data/CHANGES.md +261 -0
  6. data/CONTRIBUTING.md +16 -0
  7. data/Gemfile +3 -0
  8. data/LICENSE.txt +14 -0
  9. data/README.md +58 -0
  10. data/Rakefile +61 -0
  11. data/bin/protoc-gen-ruby +17 -0
  12. data/bin/rpc_server +4 -0
  13. data/examples/bin/reverse-client-http +4 -0
  14. data/examples/bin/reverse-client-socket +4 -0
  15. data/examples/bin/reverse-client-zmq +4 -0
  16. data/examples/config.ru +6 -0
  17. data/examples/definitions/example/reverse.proto +12 -0
  18. data/examples/lib/example/reverse-client.rb +23 -0
  19. data/examples/lib/example/reverse-service.rb +9 -0
  20. data/examples/lib/example/reverse.pb.rb +36 -0
  21. data/lib/protobuf.rb +106 -0
  22. data/lib/protobuf/cli.rb +249 -0
  23. data/lib/protobuf/code_generator.rb +41 -0
  24. data/lib/protobuf/decoder.rb +74 -0
  25. data/lib/protobuf/deprecator.rb +42 -0
  26. data/lib/protobuf/descriptors.rb +3 -0
  27. data/lib/protobuf/descriptors/google/protobuf/compiler/plugin.pb.rb +52 -0
  28. data/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb +249 -0
  29. data/lib/protobuf/encoder.rb +62 -0
  30. data/lib/protobuf/enum.rb +319 -0
  31. data/lib/protobuf/exceptions.rb +9 -0
  32. data/lib/protobuf/field.rb +74 -0
  33. data/lib/protobuf/field/base_field.rb +280 -0
  34. data/lib/protobuf/field/bool_field.rb +53 -0
  35. data/lib/protobuf/field/bytes_field.rb +81 -0
  36. data/lib/protobuf/field/double_field.rb +26 -0
  37. data/lib/protobuf/field/enum_field.rb +57 -0
  38. data/lib/protobuf/field/field_array.rb +86 -0
  39. data/lib/protobuf/field/fixed32_field.rb +25 -0
  40. data/lib/protobuf/field/fixed64_field.rb +29 -0
  41. data/lib/protobuf/field/float_field.rb +38 -0
  42. data/lib/protobuf/field/int32_field.rb +22 -0
  43. data/lib/protobuf/field/int64_field.rb +22 -0
  44. data/lib/protobuf/field/integer_field.rb +24 -0
  45. data/lib/protobuf/field/message_field.rb +66 -0
  46. data/lib/protobuf/field/sfixed32_field.rb +28 -0
  47. data/lib/protobuf/field/sfixed64_field.rb +29 -0
  48. data/lib/protobuf/field/signed_integer_field.rb +30 -0
  49. data/lib/protobuf/field/sint32_field.rb +22 -0
  50. data/lib/protobuf/field/sint64_field.rb +22 -0
  51. data/lib/protobuf/field/string_field.rb +35 -0
  52. data/lib/protobuf/field/uint32_field.rb +22 -0
  53. data/lib/protobuf/field/uint64_field.rb +22 -0
  54. data/lib/protobuf/field/varint_field.rb +68 -0
  55. data/lib/protobuf/generators/base.rb +71 -0
  56. data/lib/protobuf/generators/enum_generator.rb +42 -0
  57. data/lib/protobuf/generators/extension_generator.rb +28 -0
  58. data/lib/protobuf/generators/field_generator.rb +132 -0
  59. data/lib/protobuf/generators/file_generator.rb +140 -0
  60. data/lib/protobuf/generators/group_generator.rb +113 -0
  61. data/lib/protobuf/generators/message_generator.rb +99 -0
  62. data/lib/protobuf/generators/printable.rb +161 -0
  63. data/lib/protobuf/generators/service_generator.rb +27 -0
  64. data/lib/protobuf/http.rb +20 -0
  65. data/lib/protobuf/lifecycle.rb +46 -0
  66. data/lib/protobuf/logger.rb +86 -0
  67. data/lib/protobuf/message.rb +182 -0
  68. data/lib/protobuf/message/fields.rb +122 -0
  69. data/lib/protobuf/message/serialization.rb +84 -0
  70. data/lib/protobuf/optionable.rb +23 -0
  71. data/lib/protobuf/rpc/buffer.rb +79 -0
  72. data/lib/protobuf/rpc/client.rb +168 -0
  73. data/lib/protobuf/rpc/connector.rb +21 -0
  74. data/lib/protobuf/rpc/connectors/base.rb +54 -0
  75. data/lib/protobuf/rpc/connectors/common.rb +172 -0
  76. data/lib/protobuf/rpc/connectors/http.rb +90 -0
  77. data/lib/protobuf/rpc/connectors/socket.rb +73 -0
  78. data/lib/protobuf/rpc/connectors/zmq.rb +205 -0
  79. data/lib/protobuf/rpc/dynamic_discovery.pb.rb +47 -0
  80. data/lib/protobuf/rpc/env.rb +58 -0
  81. data/lib/protobuf/rpc/error.rb +28 -0
  82. data/lib/protobuf/rpc/error/client_error.rb +31 -0
  83. data/lib/protobuf/rpc/error/server_error.rb +43 -0
  84. data/lib/protobuf/rpc/middleware.rb +25 -0
  85. data/lib/protobuf/rpc/middleware/exception_handler.rb +36 -0
  86. data/lib/protobuf/rpc/middleware/logger.rb +91 -0
  87. data/lib/protobuf/rpc/middleware/request_decoder.rb +83 -0
  88. data/lib/protobuf/rpc/middleware/response_encoder.rb +88 -0
  89. data/lib/protobuf/rpc/middleware/runner.rb +18 -0
  90. data/lib/protobuf/rpc/rpc.pb.rb +53 -0
  91. data/lib/protobuf/rpc/server.rb +39 -0
  92. data/lib/protobuf/rpc/servers/http/server.rb +101 -0
  93. data/lib/protobuf/rpc/servers/http_runner.rb +34 -0
  94. data/lib/protobuf/rpc/servers/socket/server.rb +113 -0
  95. data/lib/protobuf/rpc/servers/socket/worker.rb +56 -0
  96. data/lib/protobuf/rpc/servers/socket_runner.rb +34 -0
  97. data/lib/protobuf/rpc/servers/zmq/broker.rb +155 -0
  98. data/lib/protobuf/rpc/servers/zmq/server.rb +313 -0
  99. data/lib/protobuf/rpc/servers/zmq/util.rb +47 -0
  100. data/lib/protobuf/rpc/servers/zmq/worker.rb +105 -0
  101. data/lib/protobuf/rpc/servers/zmq_runner.rb +51 -0
  102. data/lib/protobuf/rpc/service.rb +179 -0
  103. data/lib/protobuf/rpc/service_directory.rb +245 -0
  104. data/lib/protobuf/rpc/service_dispatcher.rb +46 -0
  105. data/lib/protobuf/rpc/service_filters.rb +273 -0
  106. data/lib/protobuf/rpc/stat.rb +148 -0
  107. data/lib/protobuf/socket.rb +22 -0
  108. data/lib/protobuf/tasks.rb +1 -0
  109. data/lib/protobuf/tasks/compile.rake +61 -0
  110. data/lib/protobuf/version.rb +3 -0
  111. data/lib/protobuf/wire_type.rb +10 -0
  112. data/lib/protobuf/zmq.rb +21 -0
  113. data/proto/dynamic_discovery.proto +44 -0
  114. data/proto/google/protobuf/compiler/plugin.proto +147 -0
  115. data/proto/google/protobuf/descriptor.proto +620 -0
  116. data/proto/rpc.proto +62 -0
  117. data/protobuffy.gemspec +37 -0
  118. data/spec/benchmark/tasks.rb +113 -0
  119. data/spec/bin/protoc-gen-ruby_spec.rb +18 -0
  120. data/spec/data/data.bin +3 -0
  121. data/spec/data/types.bin +0 -0
  122. data/spec/encoding/all_types_spec.rb +91 -0
  123. data/spec/encoding/extreme_values_spec.rb +0 -0
  124. data/spec/functional/socket_server_spec.rb +59 -0
  125. data/spec/functional/zmq_server_spec.rb +103 -0
  126. data/spec/lib/protobuf/cli_spec.rb +267 -0
  127. data/spec/lib/protobuf/code_generator_spec.rb +60 -0
  128. data/spec/lib/protobuf/enum_spec.rb +239 -0
  129. data/spec/lib/protobuf/field/int32_field_spec.rb +7 -0
  130. data/spec/lib/protobuf/field/string_field_spec.rb +46 -0
  131. data/spec/lib/protobuf/field_spec.rb +194 -0
  132. data/spec/lib/protobuf/generators/base_spec.rb +87 -0
  133. data/spec/lib/protobuf/generators/enum_generator_spec.rb +68 -0
  134. data/spec/lib/protobuf/generators/extension_generator_spec.rb +43 -0
  135. data/spec/lib/protobuf/generators/field_generator_spec.rb +99 -0
  136. data/spec/lib/protobuf/generators/file_generator_spec.rb +29 -0
  137. data/spec/lib/protobuf/generators/message_generator_spec.rb +0 -0
  138. data/spec/lib/protobuf/generators/service_generator_spec.rb +43 -0
  139. data/spec/lib/protobuf/lifecycle_spec.rb +89 -0
  140. data/spec/lib/protobuf/logger_spec.rb +136 -0
  141. data/spec/lib/protobuf/message_spec.rb +368 -0
  142. data/spec/lib/protobuf/optionable_spec.rb +46 -0
  143. data/spec/lib/protobuf/rpc/client_spec.rb +66 -0
  144. data/spec/lib/protobuf/rpc/connector_spec.rb +26 -0
  145. data/spec/lib/protobuf/rpc/connectors/base_spec.rb +50 -0
  146. data/spec/lib/protobuf/rpc/connectors/common_spec.rb +170 -0
  147. data/spec/lib/protobuf/rpc/connectors/connector_spec.rb +13 -0
  148. data/spec/lib/protobuf/rpc/connectors/http_spec.rb +61 -0
  149. data/spec/lib/protobuf/rpc/connectors/socket_spec.rb +24 -0
  150. data/spec/lib/protobuf/rpc/connectors/zmq_spec.rb +129 -0
  151. data/spec/lib/protobuf/rpc/middleware/exception_handler_spec.rb +62 -0
  152. data/spec/lib/protobuf/rpc/middleware/logger_spec.rb +49 -0
  153. data/spec/lib/protobuf/rpc/middleware/request_decoder_spec.rb +115 -0
  154. data/spec/lib/protobuf/rpc/middleware/response_encoder_spec.rb +75 -0
  155. data/spec/lib/protobuf/rpc/servers/http/server_spec.rb +104 -0
  156. data/spec/lib/protobuf/rpc/servers/socket_server_spec.rb +38 -0
  157. data/spec/lib/protobuf/rpc/servers/zmq/server_spec.rb +41 -0
  158. data/spec/lib/protobuf/rpc/servers/zmq/util_spec.rb +55 -0
  159. data/spec/lib/protobuf/rpc/servers/zmq/worker_spec.rb +35 -0
  160. data/spec/lib/protobuf/rpc/service_directory_spec.rb +295 -0
  161. data/spec/lib/protobuf/rpc/service_dispatcher_spec.rb +52 -0
  162. data/spec/lib/protobuf/rpc/service_filters_spec.rb +484 -0
  163. data/spec/lib/protobuf/rpc/service_spec.rb +161 -0
  164. data/spec/lib/protobuf/rpc/stat_spec.rb +151 -0
  165. data/spec/lib/protobuf_spec.rb +78 -0
  166. data/spec/spec_helper.rb +57 -0
  167. data/spec/support/all.rb +7 -0
  168. data/spec/support/packed_field.rb +22 -0
  169. data/spec/support/server.rb +94 -0
  170. data/spec/support/test/all_types.data.bin +0 -0
  171. data/spec/support/test/all_types.data.txt +119 -0
  172. data/spec/support/test/defaults.pb.rb +25 -0
  173. data/spec/support/test/defaults.proto +9 -0
  174. data/spec/support/test/enum.pb.rb +59 -0
  175. data/spec/support/test/enum.proto +34 -0
  176. data/spec/support/test/extended.pb.rb +22 -0
  177. data/spec/support/test/extended.proto +10 -0
  178. data/spec/support/test/extreme_values.data.bin +0 -0
  179. data/spec/support/test/google_unittest.pb.rb +543 -0
  180. data/spec/support/test/google_unittest.proto +713 -0
  181. data/spec/support/test/google_unittest_import.pb.rb +37 -0
  182. data/spec/support/test/google_unittest_import.proto +64 -0
  183. data/spec/support/test/google_unittest_import_public.pb.rb +8 -0
  184. data/spec/support/test/google_unittest_import_public.proto +38 -0
  185. data/spec/support/test/multi_field_extensions.pb.rb +56 -0
  186. data/spec/support/test/multi_field_extensions.proto +33 -0
  187. data/spec/support/test/resource.pb.rb +117 -0
  188. data/spec/support/test/resource.proto +94 -0
  189. data/spec/support/test/resource_service.rb +26 -0
  190. data/spec/support/test_app_file.rb +2 -0
  191. data/spec/support/tolerance_matcher.rb +40 -0
  192. metadata +367 -0
@@ -0,0 +1,37 @@
1
+ ##
2
+ # This file is auto-generated. DO NOT EDIT!
3
+ #
4
+ require 'protobuf/message'
5
+
6
+ module GoogleUnittestImport
7
+
8
+ ##
9
+ # Enum Classes
10
+ #
11
+ class ImportEnum < ::Protobuf::Enum
12
+ define :IMPORT_FOO, 7
13
+ define :IMPORT_BAR, 8
14
+ define :IMPORT_BAZ, 9
15
+ end
16
+
17
+
18
+ ##
19
+ # Message Classes
20
+ #
21
+ class PublicImportMessage < ::Protobuf::Message; end
22
+ class ImportMessage < ::Protobuf::Message; end
23
+
24
+
25
+ ##
26
+ # Message Fields
27
+ #
28
+ class PublicImportMessage
29
+ optional :int32, :e, 1
30
+ end
31
+
32
+ class ImportMessage
33
+ optional :int32, :d, 1
34
+ end
35
+
36
+ end
37
+
@@ -0,0 +1,64 @@
1
+ // Protocol Buffers - Google's data interchange format
2
+ // Copyright 2008 Google Inc. All rights reserved.
3
+ // http://code.google.com/p/protobuf/
4
+ //
5
+ // Redistribution and use in source and binary forms, with or without
6
+ // modification, are permitted provided that the following conditions are
7
+ // met:
8
+ //
9
+ // * Redistributions of source code must retain the above copyright
10
+ // notice, this list of conditions and the following disclaimer.
11
+ // * Redistributions in binary form must reproduce the above
12
+ // copyright notice, this list of conditions and the following disclaimer
13
+ // in the documentation and/or other materials provided with the
14
+ // distribution.
15
+ // * Neither the name of Google Inc. nor the names of its
16
+ // contributors may be used to endorse or promote products derived from
17
+ // this software without specific prior written permission.
18
+ //
19
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+
31
+ // Author: kenton@google.com (Kenton Varda)
32
+ // Based on original Protocol Buffers design by
33
+ // Sanjay Ghemawat, Jeff Dean, and others.
34
+ //
35
+ // A proto file which is imported by unittest.proto to test importing.
36
+
37
+
38
+ // We don't put this in a package within proto2 because we need to make sure
39
+ // that the generated code doesn't depend on being in the proto2 namespace.
40
+ // In test_util.h we do
41
+ // "using namespace unittest_import = protobuf_unittest_import".
42
+ package googleUnittestImport;
43
+
44
+ //############################## Test public import
45
+ // TODO: This will be supported in the next release of the
46
+ // compiler
47
+ // import public "test/google_unittest_import_public.proto";
48
+
49
+ message PublicImportMessage {
50
+ optional int32 e = 1;
51
+ }
52
+
53
+ //###############################
54
+
55
+ message ImportMessage {
56
+ optional int32 d = 1;
57
+ }
58
+
59
+ enum ImportEnum {
60
+ IMPORT_FOO = 7;
61
+ IMPORT_BAR = 8;
62
+ IMPORT_BAZ = 9;
63
+ }
64
+
@@ -0,0 +1,8 @@
1
+ ##
2
+ # This file is auto-generated. DO NOT EDIT!
3
+ #
4
+ require 'protobuf/message'
5
+
6
+ module GoogleUnittestImport
7
+ end
8
+
@@ -0,0 +1,38 @@
1
+ // Protocol Buffers - Google's data interchange format
2
+ // Copyright 2008 Google Inc. All rights reserved.
3
+ // http://code.google.com/p/protobuf/
4
+ //
5
+ // Redistribution and use in source and binary forms, with or without
6
+ // modification, are permitted provided that the following conditions are
7
+ // met:
8
+ //
9
+ // * Redistributions of source code must retain the above copyright
10
+ // notice, this list of conditions and the following disclaimer.
11
+ // * Redistributions in binary form must reproduce the above
12
+ // copyright notice, this list of conditions and the following disclaimer
13
+ // in the documentation and/or other materials provided with the
14
+ // distribution.
15
+ // * Neither the name of Google Inc. nor the names of its
16
+ // contributors may be used to endorse or promote products derived from
17
+ // this software without specific prior written permission.
18
+ //
19
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+
31
+ // Author: liujisi@google.com (Pherl Liu)
32
+
33
+
34
+ package googleUnittestImport;
35
+
36
+ //message PublicImportMessage {
37
+ // optional int32 e = 1;
38
+ //}
@@ -0,0 +1,56 @@
1
+ ##
2
+ # This file is auto-generated. DO NOT EDIT!
3
+ #
4
+ require 'protobuf/message'
5
+
6
+ module Test
7
+
8
+ ##
9
+ # Message Classes
10
+ #
11
+ class Header < ::Protobuf::Message
12
+ class Type < ::Protobuf::Enum
13
+ define :PayloadTypeA, 1
14
+ define :PayloadTypeB, 2
15
+ end
16
+
17
+ end
18
+
19
+ class PayloadA < ::Protobuf::Message
20
+ class Foo < ::Protobuf::Message; end
21
+
22
+ end
23
+
24
+ class PayloadB < ::Protobuf::Message
25
+ class Foo < ::Protobuf::Message; end
26
+
27
+ end
28
+
29
+
30
+
31
+ ##
32
+ # Message Fields
33
+ #
34
+ class Header
35
+ required ::Test::Header::Type, :type, 1
36
+ # Extension Fields
37
+ extensions 100...536870912
38
+ optional ::Test::PayloadA, :payload, 100, :extension => true
39
+ end
40
+
41
+ class PayloadA
42
+ class Foo
43
+ optional :string, :foo_a, 1
44
+ end
45
+
46
+ end
47
+
48
+ class PayloadB
49
+ class Foo
50
+ optional :string, :foo_b, 1
51
+ end
52
+
53
+ end
54
+
55
+ end
56
+
@@ -0,0 +1,33 @@
1
+ package test;
2
+
3
+ message Header {
4
+ extensions 100 to max;
5
+
6
+ enum Type {
7
+ PayloadTypeA = 1;
8
+ PayloadTypeB = 2;
9
+ }
10
+
11
+ required Type type = 1;
12
+ }
13
+
14
+ message PayloadA {
15
+ message Foo {
16
+ optional string foo_a = 1;
17
+ }
18
+
19
+ extend Header {
20
+ optional PayloadA payload = 100;
21
+ }
22
+ }
23
+
24
+ message PayloadB {
25
+ message Foo {
26
+ optional string foo_b = 1;
27
+ }
28
+
29
+ // UNCOMMENT TO TEST RUNTIME FAILING WITH MULTIPLE FIELDS
30
+ // extend Header {
31
+ // optional PayloadB payload = 101;
32
+ //}
33
+ }
@@ -0,0 +1,117 @@
1
+ ##
2
+ # This file is auto-generated. DO NOT EDIT!
3
+ #
4
+ require 'protobuf/message'
5
+ require 'protobuf/rpc/service'
6
+
7
+ module Test
8
+
9
+ ##
10
+ # Enum Classes
11
+ #
12
+ class StatusType < ::Protobuf::Enum
13
+ define :PENDING, 0
14
+ define :ENABLED, 1
15
+ define :DISABLED, 2
16
+ define :DELETED, 3
17
+ end
18
+
19
+
20
+ ##
21
+ # Message Classes
22
+ #
23
+ class ResourceFindRequest < ::Protobuf::Message; end
24
+ class ResourceSleepRequest < ::Protobuf::Message; end
25
+ class Resource < ::Protobuf::Message; end
26
+ class ResourceWithRequiredField < ::Protobuf::Message; end
27
+ class Searchable < ::Protobuf::Message
28
+ class SearchType < ::Protobuf::Enum
29
+ define :FLAT, 1
30
+ define :NESTED, 2
31
+ end
32
+
33
+ end
34
+
35
+ class MessageParent < ::Protobuf::Message
36
+ class MessageChild < ::Protobuf::Message; end
37
+
38
+ end
39
+
40
+ class Nested < ::Protobuf::Message
41
+ class NestedLevelOne < ::Protobuf::Message; end
42
+
43
+ end
44
+
45
+
46
+
47
+ ##
48
+ # Message Fields
49
+ #
50
+ class ResourceFindRequest
51
+ required :string, :name, 1
52
+ optional :bool, :active, 2
53
+ repeated :string, :widgets, 3
54
+ repeated :bytes, :widget_bytes, 4
55
+ end
56
+
57
+ class ResourceSleepRequest
58
+ optional :int32, :sleep, 1
59
+ end
60
+
61
+ class Resource
62
+ required :string, :name, 1
63
+ optional :int64, :date_created, 2
64
+ optional ::Test::StatusType, :status, 3
65
+ repeated ::Test::StatusType, :repeated_enum, 4
66
+ # Extension Fields
67
+ extensions 100...536870912
68
+ optional :bool, :ext_is_searchable, 100, :extension => true
69
+ optional :bool, :ext_is_hidden, 101, :extension => true
70
+ optional ::Test::Searchable::SearchType, :ext_search_type, 102, :default => ::Test::Searchable::SearchType::FLAT, :extension => true
71
+ optional :bool, :ext_nested_in_level_one, 105, :extension => true
72
+ optional :bool, :ext_dup_field, 106, :extension => true
73
+ end
74
+
75
+ class ResourceWithRequiredField
76
+ required :string, :foo_is_required, 1
77
+ end
78
+
79
+ class MessageParent
80
+ class MessageChild
81
+ optional :string, :child1, 1
82
+ end
83
+
84
+ end
85
+
86
+ class Nested
87
+ class NestedLevelOne
88
+ optional :bool, :level_one, 1, :default => true
89
+ # Extension Fields
90
+ extensions 100...102
91
+ optional :bool, :ext_nested_level_one_outer, 101, :extension => true
92
+ optional :bool, :ext_nested_level_one, 100, :extension => true
93
+ end
94
+
95
+ optional :string, :name, 1
96
+ optional ::Test::Resource, :resource, 2
97
+ repeated ::Test::Resource, :multiple_resources, 3
98
+ optional ::Test::StatusType, :status, 4
99
+ # Extension Fields
100
+ extensions 100...111
101
+ optional :string, :foo, 100, :extension => true
102
+ optional :int64, :bar, 101, :extension => true
103
+ end
104
+
105
+
106
+ ##
107
+ # Service Classes
108
+ #
109
+ class ResourceService < ::Protobuf::Rpc::Service
110
+ rpc :find, ::Test::ResourceFindRequest, ::Test::Resource
111
+ rpc :find_with_rpc_failed, ::Test::ResourceFindRequest, ::Test::Resource
112
+ rpc :find_with_sleep, ::Test::ResourceSleepRequest, ::Test::Resource
113
+ rpc :find_not_implemented, ::Test::ResourceFindRequest, ::Test::Resource
114
+ end
115
+
116
+ end
117
+
@@ -0,0 +1,94 @@
1
+ package test;
2
+
3
+ enum StatusType {
4
+ PENDING = 0;
5
+ ENABLED = 1;
6
+ DISABLED = 2;
7
+ DELETED = 3;
8
+ }
9
+
10
+ message ResourceFindRequest {
11
+ required string name = 1;
12
+ optional bool active = 2;
13
+ repeated string widgets = 3;
14
+ repeated bytes widget_bytes = 4;
15
+ }
16
+
17
+ message ResourceSleepRequest {
18
+ optional int32 sleep = 1;
19
+ }
20
+
21
+ message Resource {
22
+ extensions 100 to max;
23
+
24
+ required string name = 1;
25
+ optional int64 date_created = 2;
26
+ optional StatusType status = 3;
27
+ repeated StatusType repeated_enum = 4;
28
+ }
29
+
30
+ message ResourceWithRequiredField {
31
+ required string foo_is_required = 1;
32
+ }
33
+
34
+ message Searchable {
35
+ enum SearchType {
36
+ FLAT = 1;
37
+ NESTED = 2;
38
+ }
39
+
40
+ extend test.Resource {
41
+ optional bool ext_is_searchable = 100;
42
+ optional bool ext_is_hidden = 101;
43
+ optional Searchable.SearchType ext_search_type = 102 [default=FLAT];
44
+ }
45
+ }
46
+
47
+ message MessageParent {
48
+ message MessageChild {
49
+ optional string child1 = 1;
50
+ }
51
+ }
52
+
53
+ message Nested {
54
+ extensions 100 to 110;
55
+
56
+ optional string name = 1;
57
+ optional Resource resource = 2;
58
+ repeated Resource multiple_resources = 3;
59
+ optional StatusType status = 4;
60
+
61
+ message NestedLevelOne {
62
+ extensions 100 to 101;
63
+ optional bool level_one = 1 [default=true];
64
+
65
+ extend Resource {
66
+ optional bool ext_nested_in_level_one = 105;
67
+ optional bool ext_dup_field = 106;
68
+ }
69
+ }
70
+
71
+ extend NestedLevelOne {
72
+ optional bool ext_nested_level_one = 100;
73
+ }
74
+
75
+ // extend Resource {
76
+ // optional bool ext_dup_field = 107;
77
+ // }
78
+ }
79
+
80
+ extend Nested {
81
+ optional string foo = 100;
82
+ optional int64 bar = 101;
83
+ }
84
+
85
+ extend Nested.NestedLevelOne {
86
+ optional bool ext_nested_level_one_outer = 101;
87
+ }
88
+
89
+ service ResourceService {
90
+ rpc Find (ResourceFindRequest) returns (Resource);
91
+ rpc FindWithRpcFailed (ResourceFindRequest) returns (Resource);
92
+ rpc FindWithSleep (ResourceSleepRequest) returns (Resource);
93
+ rpc FindNotImplemented (ResourceFindRequest) returns (Resource);
94
+ }