prepor-protobuf 3.5.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 (182) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/.rubocop.yml +51 -0
  4. data/.rubocop_todo.yml +89 -0
  5. data/.travis.yml +25 -0
  6. data/.yardopts +5 -0
  7. data/CHANGES.md +256 -0
  8. data/CONTRIBUTING.md +16 -0
  9. data/Gemfile +3 -0
  10. data/LICENSE.txt +22 -0
  11. data/README.md +33 -0
  12. data/Rakefile +64 -0
  13. data/bin/protoc-gen-ruby +16 -0
  14. data/bin/rpc_server +5 -0
  15. data/install-protobuf.sh +28 -0
  16. data/lib/protobuf.rb +100 -0
  17. data/lib/protobuf/cli.rb +242 -0
  18. data/lib/protobuf/code_generator.rb +44 -0
  19. data/lib/protobuf/decoder.rb +73 -0
  20. data/lib/protobuf/deprecation.rb +112 -0
  21. data/lib/protobuf/descriptors.rb +3 -0
  22. data/lib/protobuf/descriptors/google/protobuf/compiler/plugin.pb.rb +48 -0
  23. data/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb +251 -0
  24. data/lib/protobuf/encoder.rb +67 -0
  25. data/lib/protobuf/enum.rb +303 -0
  26. data/lib/protobuf/exceptions.rb +9 -0
  27. data/lib/protobuf/field.rb +74 -0
  28. data/lib/protobuf/field/base_field.rb +267 -0
  29. data/lib/protobuf/field/bool_field.rb +59 -0
  30. data/lib/protobuf/field/bytes_field.rb +82 -0
  31. data/lib/protobuf/field/double_field.rb +25 -0
  32. data/lib/protobuf/field/enum_field.rb +68 -0
  33. data/lib/protobuf/field/field_array.rb +87 -0
  34. data/lib/protobuf/field/fixed32_field.rb +25 -0
  35. data/lib/protobuf/field/fixed64_field.rb +28 -0
  36. data/lib/protobuf/field/float_field.rb +41 -0
  37. data/lib/protobuf/field/int32_field.rb +21 -0
  38. data/lib/protobuf/field/int64_field.rb +21 -0
  39. data/lib/protobuf/field/integer_field.rb +23 -0
  40. data/lib/protobuf/field/message_field.rb +65 -0
  41. data/lib/protobuf/field/sfixed32_field.rb +27 -0
  42. data/lib/protobuf/field/sfixed64_field.rb +28 -0
  43. data/lib/protobuf/field/signed_integer_field.rb +29 -0
  44. data/lib/protobuf/field/sint32_field.rb +21 -0
  45. data/lib/protobuf/field/sint64_field.rb +21 -0
  46. data/lib/protobuf/field/string_field.rb +34 -0
  47. data/lib/protobuf/field/uint32_field.rb +21 -0
  48. data/lib/protobuf/field/uint64_field.rb +21 -0
  49. data/lib/protobuf/field/varint_field.rb +73 -0
  50. data/lib/protobuf/generators/base.rb +70 -0
  51. data/lib/protobuf/generators/enum_generator.rb +41 -0
  52. data/lib/protobuf/generators/extension_generator.rb +27 -0
  53. data/lib/protobuf/generators/field_generator.rb +131 -0
  54. data/lib/protobuf/generators/file_generator.rb +135 -0
  55. data/lib/protobuf/generators/group_generator.rb +112 -0
  56. data/lib/protobuf/generators/message_generator.rb +98 -0
  57. data/lib/protobuf/generators/printable.rb +160 -0
  58. data/lib/protobuf/generators/service_generator.rb +26 -0
  59. data/lib/protobuf/lifecycle.rb +33 -0
  60. data/lib/protobuf/logging.rb +39 -0
  61. data/lib/protobuf/message.rb +193 -0
  62. data/lib/protobuf/message/fields.rb +133 -0
  63. data/lib/protobuf/message/serialization.rb +89 -0
  64. data/lib/protobuf/optionable.rb +23 -0
  65. data/lib/protobuf/rpc/buffer.rb +77 -0
  66. data/lib/protobuf/rpc/client.rb +168 -0
  67. data/lib/protobuf/rpc/connector.rb +19 -0
  68. data/lib/protobuf/rpc/connectors/base.rb +55 -0
  69. data/lib/protobuf/rpc/connectors/common.rb +176 -0
  70. data/lib/protobuf/rpc/connectors/socket.rb +73 -0
  71. data/lib/protobuf/rpc/connectors/zmq.rb +322 -0
  72. data/lib/protobuf/rpc/dynamic_discovery.pb.rb +49 -0
  73. data/lib/protobuf/rpc/env.rb +58 -0
  74. data/lib/protobuf/rpc/error.rb +28 -0
  75. data/lib/protobuf/rpc/error/client_error.rb +31 -0
  76. data/lib/protobuf/rpc/error/server_error.rb +43 -0
  77. data/lib/protobuf/rpc/middleware.rb +25 -0
  78. data/lib/protobuf/rpc/middleware/exception_handler.rb +36 -0
  79. data/lib/protobuf/rpc/middleware/logger.rb +91 -0
  80. data/lib/protobuf/rpc/middleware/request_decoder.rb +83 -0
  81. data/lib/protobuf/rpc/middleware/response_encoder.rb +88 -0
  82. data/lib/protobuf/rpc/middleware/runner.rb +18 -0
  83. data/lib/protobuf/rpc/rpc.pb.rb +55 -0
  84. data/lib/protobuf/rpc/server.rb +39 -0
  85. data/lib/protobuf/rpc/servers/socket/server.rb +123 -0
  86. data/lib/protobuf/rpc/servers/socket/worker.rb +56 -0
  87. data/lib/protobuf/rpc/servers/socket_runner.rb +40 -0
  88. data/lib/protobuf/rpc/servers/zmq/broker.rb +193 -0
  89. data/lib/protobuf/rpc/servers/zmq/server.rb +320 -0
  90. data/lib/protobuf/rpc/servers/zmq/util.rb +48 -0
  91. data/lib/protobuf/rpc/servers/zmq/worker.rb +104 -0
  92. data/lib/protobuf/rpc/servers/zmq_runner.rb +62 -0
  93. data/lib/protobuf/rpc/service.rb +179 -0
  94. data/lib/protobuf/rpc/service_directory.rb +253 -0
  95. data/lib/protobuf/rpc/service_dispatcher.rb +46 -0
  96. data/lib/protobuf/rpc/service_filters.rb +272 -0
  97. data/lib/protobuf/rpc/stat.rb +97 -0
  98. data/lib/protobuf/socket.rb +21 -0
  99. data/lib/protobuf/tasks.rb +1 -0
  100. data/lib/protobuf/tasks/compile.rake +61 -0
  101. data/lib/protobuf/version.rb +3 -0
  102. data/lib/protobuf/wire_type.rb +10 -0
  103. data/lib/protobuf/zmq.rb +21 -0
  104. data/proto/dynamic_discovery.proto +44 -0
  105. data/proto/google/protobuf/compiler/plugin.proto +147 -0
  106. data/proto/google/protobuf/descriptor.proto +620 -0
  107. data/proto/rpc.proto +62 -0
  108. data/protobuf.gemspec +51 -0
  109. data/spec/benchmark/tasks.rb +139 -0
  110. data/spec/bin/protoc-gen-ruby_spec.rb +23 -0
  111. data/spec/data/data.bin +3 -0
  112. data/spec/data/types.bin +0 -0
  113. data/spec/encoding/all_types_spec.rb +105 -0
  114. data/spec/encoding/extreme_values_spec.rb +0 -0
  115. data/spec/functional/class_inheritance_spec.rb +52 -0
  116. data/spec/functional/socket_server_spec.rb +59 -0
  117. data/spec/functional/zmq_server_spec.rb +105 -0
  118. data/spec/lib/protobuf/cli_spec.rb +273 -0
  119. data/spec/lib/protobuf/code_generator_spec.rb +60 -0
  120. data/spec/lib/protobuf/enum_spec.rb +265 -0
  121. data/spec/lib/protobuf/field/bool_field_spec.rb +51 -0
  122. data/spec/lib/protobuf/field/field_array_spec.rb +69 -0
  123. data/spec/lib/protobuf/field/float_field_spec.rb +55 -0
  124. data/spec/lib/protobuf/field/int32_field_spec.rb +89 -0
  125. data/spec/lib/protobuf/field/string_field_spec.rb +45 -0
  126. data/spec/lib/protobuf/field_spec.rb +191 -0
  127. data/spec/lib/protobuf/generators/base_spec.rb +84 -0
  128. data/spec/lib/protobuf/generators/enum_generator_spec.rb +73 -0
  129. data/spec/lib/protobuf/generators/extension_generator_spec.rb +42 -0
  130. data/spec/lib/protobuf/generators/field_generator_spec.rb +102 -0
  131. data/spec/lib/protobuf/generators/file_generator_spec.rb +32 -0
  132. data/spec/lib/protobuf/generators/message_generator_spec.rb +0 -0
  133. data/spec/lib/protobuf/generators/service_generator_spec.rb +46 -0
  134. data/spec/lib/protobuf/lifecycle_spec.rb +94 -0
  135. data/spec/lib/protobuf/message_spec.rb +526 -0
  136. data/spec/lib/protobuf/optionable_spec.rb +46 -0
  137. data/spec/lib/protobuf/rpc/client_spec.rb +66 -0
  138. data/spec/lib/protobuf/rpc/connector_spec.rb +26 -0
  139. data/spec/lib/protobuf/rpc/connectors/base_spec.rb +50 -0
  140. data/spec/lib/protobuf/rpc/connectors/common_spec.rb +170 -0
  141. data/spec/lib/protobuf/rpc/connectors/socket_spec.rb +36 -0
  142. data/spec/lib/protobuf/rpc/connectors/zmq_spec.rb +117 -0
  143. data/spec/lib/protobuf/rpc/middleware/exception_handler_spec.rb +62 -0
  144. data/spec/lib/protobuf/rpc/middleware/logger_spec.rb +49 -0
  145. data/spec/lib/protobuf/rpc/middleware/request_decoder_spec.rb +115 -0
  146. data/spec/lib/protobuf/rpc/middleware/response_encoder_spec.rb +75 -0
  147. data/spec/lib/protobuf/rpc/servers/socket_server_spec.rb +38 -0
  148. data/spec/lib/protobuf/rpc/servers/zmq/server_spec.rb +43 -0
  149. data/spec/lib/protobuf/rpc/servers/zmq/util_spec.rb +55 -0
  150. data/spec/lib/protobuf/rpc/servers/zmq/worker_spec.rb +35 -0
  151. data/spec/lib/protobuf/rpc/service_directory_spec.rb +293 -0
  152. data/spec/lib/protobuf/rpc/service_dispatcher_spec.rb +52 -0
  153. data/spec/lib/protobuf/rpc/service_filters_spec.rb +517 -0
  154. data/spec/lib/protobuf/rpc/service_spec.rb +162 -0
  155. data/spec/lib/protobuf/rpc/stat_spec.rb +68 -0
  156. data/spec/lib/protobuf_spec.rb +98 -0
  157. data/spec/spec_helper.rb +44 -0
  158. data/spec/support/all.rb +6 -0
  159. data/spec/support/packed_field.rb +22 -0
  160. data/spec/support/server.rb +64 -0
  161. data/spec/support/test/all_types.data.bin +0 -0
  162. data/spec/support/test/all_types.data.txt +119 -0
  163. data/spec/support/test/defaults.pb.rb +27 -0
  164. data/spec/support/test/defaults.proto +9 -0
  165. data/spec/support/test/enum.pb.rb +55 -0
  166. data/spec/support/test/enum.proto +34 -0
  167. data/spec/support/test/extended.pb.rb +18 -0
  168. data/spec/support/test/extended.proto +10 -0
  169. data/spec/support/test/extreme_values.data.bin +0 -0
  170. data/spec/support/test/google_unittest.pb.rb +537 -0
  171. data/spec/support/test/google_unittest.proto +713 -0
  172. data/spec/support/test/google_unittest_import.pb.rb +39 -0
  173. data/spec/support/test/google_unittest_import.proto +64 -0
  174. data/spec/support/test/google_unittest_import_public.pb.rb +10 -0
  175. data/spec/support/test/google_unittest_import_public.proto +38 -0
  176. data/spec/support/test/multi_field_extensions.pb.rb +58 -0
  177. data/spec/support/test/multi_field_extensions.proto +33 -0
  178. data/spec/support/test/resource.pb.rb +119 -0
  179. data/spec/support/test/resource.proto +94 -0
  180. data/spec/support/test/resource_service.rb +23 -0
  181. data/spec/support/test_app_file.rb +2 -0
  182. metadata +502 -0
@@ -0,0 +1,39 @@
1
+ # encoding: utf-8
2
+
3
+ ##
4
+ # This file is auto-generated. DO NOT EDIT!
5
+ #
6
+ require 'protobuf/message'
7
+
8
+ module GoogleUnittestImport
9
+
10
+ ##
11
+ # Enum Classes
12
+ #
13
+ class ImportEnum < ::Protobuf::Enum
14
+ define :IMPORT_FOO, 7
15
+ define :IMPORT_BAR, 8
16
+ define :IMPORT_BAZ, 9
17
+ end
18
+
19
+
20
+ ##
21
+ # Message Classes
22
+ #
23
+ class PublicImportMessage < ::Protobuf::Message; end
24
+ class ImportMessage < ::Protobuf::Message; end
25
+
26
+
27
+ ##
28
+ # Message Fields
29
+ #
30
+ class PublicImportMessage
31
+ optional :int32, :e, 1
32
+ end
33
+
34
+ class ImportMessage
35
+ optional :int32, :d, 1
36
+ end
37
+
38
+ end
39
+
@@ -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,10 @@
1
+ # encoding: utf-8
2
+
3
+ ##
4
+ # This file is auto-generated. DO NOT EDIT!
5
+ #
6
+ require 'protobuf/message'
7
+
8
+ module GoogleUnittestImport
9
+ end
10
+
@@ -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,58 @@
1
+ # encoding: utf-8
2
+
3
+ ##
4
+ # This file is auto-generated. DO NOT EDIT!
5
+ #
6
+ require 'protobuf/message'
7
+
8
+ module Test
9
+
10
+ ##
11
+ # Message Classes
12
+ #
13
+ class Header < ::Protobuf::Message
14
+ class Type < ::Protobuf::Enum
15
+ define :PayloadTypeA, 1
16
+ define :PayloadTypeB, 2
17
+ end
18
+
19
+ end
20
+
21
+ class PayloadA < ::Protobuf::Message
22
+ class Foo < ::Protobuf::Message; end
23
+
24
+ end
25
+
26
+ class PayloadB < ::Protobuf::Message
27
+ class Foo < ::Protobuf::Message; end
28
+
29
+ end
30
+
31
+
32
+
33
+ ##
34
+ # Message Fields
35
+ #
36
+ class Header
37
+ required ::Test::Header::Type, :type, 1
38
+ # Extension Fields
39
+ extensions 100...536870912
40
+ optional ::Test::PayloadA, :payload, 100, :extension => true
41
+ end
42
+
43
+ class PayloadA
44
+ class Foo
45
+ optional :string, :foo_a, 1
46
+ end
47
+
48
+ end
49
+
50
+ class PayloadB
51
+ class Foo
52
+ optional :string, :foo_b, 1
53
+ end
54
+
55
+ end
56
+
57
+ end
58
+
@@ -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,119 @@
1
+ # encoding: utf-8
2
+
3
+ ##
4
+ # This file is auto-generated. DO NOT EDIT!
5
+ #
6
+ require 'protobuf/message'
7
+ require 'protobuf/rpc/service'
8
+
9
+ module Test
10
+
11
+ ##
12
+ # Enum Classes
13
+ #
14
+ class StatusType < ::Protobuf::Enum
15
+ define :PENDING, 0
16
+ define :ENABLED, 1
17
+ define :DISABLED, 2
18
+ define :DELETED, 3
19
+ end
20
+
21
+
22
+ ##
23
+ # Message Classes
24
+ #
25
+ class ResourceFindRequest < ::Protobuf::Message; end
26
+ class ResourceSleepRequest < ::Protobuf::Message; end
27
+ class Resource < ::Protobuf::Message; end
28
+ class ResourceWithRequiredField < ::Protobuf::Message; end
29
+ class Searchable < ::Protobuf::Message
30
+ class SearchType < ::Protobuf::Enum
31
+ define :FLAT, 1
32
+ define :NESTED, 2
33
+ end
34
+
35
+ end
36
+
37
+ class MessageParent < ::Protobuf::Message
38
+ class MessageChild < ::Protobuf::Message; end
39
+
40
+ end
41
+
42
+ class Nested < ::Protobuf::Message
43
+ class NestedLevelOne < ::Protobuf::Message; end
44
+
45
+ end
46
+
47
+
48
+
49
+ ##
50
+ # Message Fields
51
+ #
52
+ class ResourceFindRequest
53
+ required :string, :name, 1
54
+ optional :bool, :active, 2
55
+ repeated :string, :widgets, 3
56
+ repeated :bytes, :widget_bytes, 4
57
+ end
58
+
59
+ class ResourceSleepRequest
60
+ optional :int32, :sleep, 1
61
+ end
62
+
63
+ class Resource
64
+ required :string, :name, 1
65
+ optional :int64, :date_created, 2
66
+ optional ::Test::StatusType, :status, 3
67
+ repeated ::Test::StatusType, :repeated_enum, 4
68
+ # Extension Fields
69
+ extensions 100...536870912
70
+ optional :bool, :ext_is_searchable, 100, :extension => true
71
+ optional :bool, :ext_is_hidden, 101, :extension => true
72
+ optional ::Test::Searchable::SearchType, :ext_search_type, 102, :default => ::Test::Searchable::SearchType::FLAT, :extension => true
73
+ optional :bool, :ext_nested_in_level_one, 105, :extension => true
74
+ optional :bool, :ext_dup_field, 106, :extension => true
75
+ end
76
+
77
+ class ResourceWithRequiredField
78
+ required :string, :foo_is_required, 1
79
+ end
80
+
81
+ class MessageParent
82
+ class MessageChild
83
+ optional :string, :child1, 1
84
+ end
85
+
86
+ end
87
+
88
+ class Nested
89
+ class NestedLevelOne
90
+ optional :bool, :level_one, 1, :default => true
91
+ # Extension Fields
92
+ extensions 100...102
93
+ optional :bool, :ext_nested_level_one_outer, 101, :extension => true
94
+ optional :bool, :ext_nested_level_one, 100, :extension => true
95
+ end
96
+
97
+ optional :string, :name, 1
98
+ optional ::Test::Resource, :resource, 2
99
+ repeated ::Test::Resource, :multiple_resources, 3
100
+ optional ::Test::StatusType, :status, 4
101
+ # Extension Fields
102
+ extensions 100...111
103
+ optional :string, :foo, 100, :extension => true
104
+ optional :int64, :bar, 101, :extension => true
105
+ end
106
+
107
+
108
+ ##
109
+ # Service Classes
110
+ #
111
+ class ResourceService < ::Protobuf::Rpc::Service
112
+ rpc :find, ::Test::ResourceFindRequest, ::Test::Resource
113
+ rpc :find_with_rpc_failed, ::Test::ResourceFindRequest, ::Test::Resource
114
+ rpc :find_with_sleep, ::Test::ResourceSleepRequest, ::Test::Resource
115
+ rpc :find_not_implemented, ::Test::ResourceFindRequest, ::Test::Resource
116
+ end
117
+
118
+ end
119
+
@@ -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
+ }