protobuf 3.6.12 → 3.7.0.pre0

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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +4 -4
  3. data/CHANGES.md +14 -3
  4. data/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb +39 -2
  5. data/lib/protobuf/field.rb +2 -2
  6. data/lib/protobuf/field/base_field.rb +27 -84
  7. data/lib/protobuf/field/bool_field.rb +3 -13
  8. data/lib/protobuf/field/bytes_field.rb +10 -26
  9. data/lib/protobuf/field/enum_field.rb +10 -20
  10. data/lib/protobuf/field/message_field.rb +13 -23
  11. data/lib/protobuf/generators/enum_generator.rb +1 -0
  12. data/lib/protobuf/generators/field_generator.rb +8 -2
  13. data/lib/protobuf/generators/file_generator.rb +8 -0
  14. data/lib/protobuf/generators/service_generator.rb +2 -2
  15. data/lib/protobuf/message.rb +47 -12
  16. data/lib/protobuf/message/fields.rb +80 -8
  17. data/lib/protobuf/rpc/connectors/common.rb +1 -1
  18. data/lib/protobuf/rpc/connectors/ping.rb +2 -2
  19. data/lib/protobuf/rpc/connectors/zmq.rb +1 -1
  20. data/lib/protobuf/rpc/middleware/exception_handler.rb +0 -4
  21. data/lib/protobuf/rpc/middleware/logger.rb +0 -4
  22. data/lib/protobuf/rpc/middleware/request_decoder.rb +16 -11
  23. data/lib/protobuf/rpc/middleware/response_encoder.rb +20 -15
  24. data/lib/protobuf/rpc/service.rb +10 -2
  25. data/lib/protobuf/rpc/service_directory.rb +0 -8
  26. data/lib/protobuf/rpc/service_dispatcher.rb +6 -5
  27. data/lib/protobuf/rpc/service_filters.rb +30 -8
  28. data/lib/protobuf/version.rb +1 -1
  29. data/proto/google/protobuf/descriptor.proto +190 -31
  30. data/spec/lib/protobuf/field/bool_field_spec.rb +33 -7
  31. data/spec/lib/protobuf/field/enum_field_spec.rb +26 -0
  32. data/spec/lib/protobuf/field/float_field_spec.rb +32 -1
  33. data/spec/lib/protobuf/field/int32_field_spec.rb +32 -1
  34. data/spec/lib/protobuf/field/message_field_spec.rb +79 -0
  35. data/spec/lib/protobuf/field/string_field_spec.rb +34 -0
  36. data/spec/lib/protobuf/field_spec.rb +1 -0
  37. data/spec/lib/protobuf/generators/enum_generator_spec.rb +9 -0
  38. data/spec/lib/protobuf/generators/service_generator_spec.rb +9 -0
  39. data/spec/lib/protobuf/message_spec.rb +328 -63
  40. data/spec/lib/protobuf/rpc/connectors/ping_spec.rb +3 -3
  41. data/spec/lib/protobuf/rpc/service_dispatcher_spec.rb +18 -1
  42. data/spec/support/protos/enum.pb.rb +1 -1
  43. data/spec/support/protos/google_unittest.pb.rb +113 -111
  44. data/spec/support/protos/google_unittest.proto +7 -0
  45. data/spec/support/protos/multi_field_extensions.pb.rb +1 -1
  46. data/spec/support/protos/resource.pb.rb +9 -9
  47. metadata +79 -5
@@ -8,10 +8,6 @@ module Protobuf
8
8
 
9
9
  # TODO: Figure out how to control when logs are flushed
10
10
  def call(env)
11
- dup._call(env)
12
- end
13
-
14
- def _call(env)
15
11
  instrumenter.start
16
12
  instrumenter.flush(env) # Log request stats
17
13
 
@@ -11,13 +11,8 @@ module Protobuf
11
11
  end
12
12
 
13
13
  def call(env)
14
- dup._call(env)
15
- end
16
-
17
- def _call(env)
18
14
  @env = env
19
15
 
20
- logger.debug { sign_message("Decoding request: #{env.encoded_request}") }
21
16
  env.service_name = service_name
22
17
  env.method_name = method_name
23
18
  env.request = request
@@ -38,15 +33,22 @@ module Protobuf
38
33
  private
39
34
 
40
35
  def method_name
41
- return @method_name unless @method_name.nil?
36
+ @method_name ||= begin
37
+ method_name = request_wrapper.method_name.underscore.to_sym
38
+
39
+ unless service.rpc_method?(method_name)
40
+ fail MethodNotFound, "#{service.name}##{method_name} is not a defined RPC method."
41
+ end
42
42
 
43
- @method_name = request_wrapper.method_name.underscore.to_sym
44
- fail MethodNotFound, "#{service.name}##{@method_name} is not a defined RPC method." unless service.rpc_method?(@method_name)
45
- @method_name
43
+ method_name
44
+ end
46
45
  end
47
46
 
48
47
  def request
49
- @request ||= rpc_method.request_type.decode(request_wrapper.request_proto)
48
+ @request ||= begin
49
+ data = request_wrapper.request_proto
50
+ rpc_method.request_type.decode(data)
51
+ end
50
52
  rescue => exception
51
53
  raise BadRequestData, "Unable to decode request: #{exception.message}"
52
54
  end
@@ -54,7 +56,10 @@ module Protobuf
54
56
  # Decode the incoming request object into our expected request object
55
57
  #
56
58
  def request_wrapper
57
- @request_wrapper ||= Socketrpc::Request.decode(env.encoded_request)
59
+ @request_wrapper ||= begin
60
+ logger.debug { sign_message("Decoding request: #{env.encoded_request}") }
61
+ Socketrpc::Request.decode(env.encoded_request)
62
+ end
58
63
  rescue => exception
59
64
  raise BadRequestData, "Unable to decode request: #{exception.message}"
60
65
  end
@@ -11,10 +11,6 @@ module Protobuf
11
11
  end
12
12
 
13
13
  def call(env)
14
- dup._call(env)
15
- end
16
-
17
- def _call(env)
18
14
  @env = app.call(env)
19
15
 
20
16
  env.response = response
@@ -45,23 +41,32 @@ module Protobuf
45
41
  # Prod the object to see if we can produce a proto object as a response
46
42
  # candidate. Validate the candidate protos.
47
43
  def response
48
- return @response unless @response.nil?
49
-
50
- candidate = env.response
51
- return @response = validate!(candidate) if candidate.is_a?(Message)
52
- return @response = validate!(candidate.to_proto) if candidate.respond_to?(:to_proto)
53
- return @response = env.response_type.new(candidate.to_hash) if candidate.respond_to?(:to_hash)
54
- return @response = candidate if candidate.is_a?(PbError)
55
-
56
- @response = validate!(candidate)
44
+ @response ||= begin
45
+ candidate = env.response
46
+ case
47
+ when candidate.is_a?(Message) then
48
+ validate!(candidate)
49
+ when candidate.respond_to?(:to_proto) then
50
+ validate!(candidate.to_proto)
51
+ when candidate.respond_to?(:to_hash) then
52
+ env.response_type.new(candidate.to_hash)
53
+ when candidate.is_a?(PbError) then
54
+ candidate
55
+ else
56
+ validate!(candidate)
57
+ end
58
+ end
57
59
  end
58
60
 
59
61
  # Ensure that the response candidate we've been given is of the type
60
62
  # we expect so that deserialization on the client side works.
61
63
  #
62
64
  def validate!(candidate)
63
- if candidate.class != env.response_type
64
- fail BadResponseProto, "Expected response to be of type #{env.response_type.name} but was #{candidate.class.name}"
65
+ actual = candidate.class
66
+ expected = env.response_type
67
+
68
+ if expected != actual
69
+ fail BadResponseProto, "Expected response to be of type #{expected.name} but was #{actual.name}"
65
70
  end
66
71
 
67
72
  candidate
@@ -119,8 +119,16 @@ module Protobuf
119
119
  rpcs.key?(name)
120
120
  end
121
121
 
122
- def call(method_name)
123
- run_filters(method_name)
122
+ ##
123
+ # Instance Methods
124
+ #
125
+ # Get a callable object that will be used by the dispatcher
126
+ # to invoke the specified rpc method. Facilitates callback dispatch.
127
+ # The returned lambda is expected to be called at a later time (which
128
+ # is why we wrap the method call).
129
+ #
130
+ def callable_rpc_method(method_name)
131
+ -> { run_filters(method_name) }
124
132
  end
125
133
 
126
134
  # Response object for this rpc cycle. Not assignable.
@@ -9,14 +9,6 @@ require 'protobuf/rpc/dynamic_discovery.pb'
9
9
 
10
10
  module Protobuf
11
11
  module Rpc
12
- def self.service_directory
13
- @service_directory ||= ::Protobuf::Rpc::ServiceDirectory.instance
14
- end
15
-
16
- def self.service_directory=(directory)
17
- @service_directory = directory
18
- end
19
-
20
12
  class ServiceDirectory
21
13
  include ::Singleton
22
14
  include ::Protobuf::Logging
@@ -12,10 +12,6 @@ module Protobuf
12
12
  end
13
13
 
14
14
  def call(env)
15
- dup._call(env)
16
- end
17
-
18
- def _call(env)
19
15
  @env = env
20
16
 
21
17
  env.response = dispatch_rpc_request
@@ -28,8 +24,13 @@ module Protobuf
28
24
 
29
25
  private
30
26
 
27
+ # Call the given service method.
31
28
  def dispatch_rpc_request
32
- rpc_service.call(method_name)
29
+ unless rpc_service.respond_to?(method_name)
30
+ fail MethodNotFound, "#{service_name}##{method_name} is not a publicly defined method."
31
+ end
32
+
33
+ rpc_service.callable_rpc_method(method_name).call
33
34
  rpc_service.response
34
35
  end
35
36
 
@@ -120,9 +120,15 @@ module Protobuf
120
120
  # or an object that responds to `call`.
121
121
  #
122
122
  def invoke_via_if?(_rpc_method, filter)
123
- if_check = filter.fetch(:if, nil)
124
- return true if if_check.nil?
125
- call_or_send(if_check)
123
+ if_check = filter.fetch(:if) { ->(_service) { return true } }
124
+ do_invoke = case
125
+ when if_check.nil?
126
+ true
127
+ else
128
+ call_or_send(if_check)
129
+ end
130
+
131
+ do_invoke
126
132
  end
127
133
 
128
134
  # If the target rpc endpoint method is listed in the :only option,
@@ -144,9 +150,15 @@ module Protobuf
144
150
  # or an object that responds to `call`.
145
151
  #
146
152
  def invoke_via_unless?(_rpc_method, filter)
147
- unless_check = filter.fetch(:unless, nil)
148
- return true if unless_check.nil?
149
- !call_or_send(unless_check)
153
+ unless_check = filter.fetch(:unless) { ->(_service) { return false } }
154
+ skip_invoke = case
155
+ when unless_check.nil?
156
+ false
157
+ else
158
+ call_or_send(unless_check)
159
+ end
160
+
161
+ !skip_invoke
150
162
  end
151
163
 
152
164
  def rescue_filters
@@ -241,10 +253,20 @@ module Protobuf
241
253
  # __send__ assuming that we respond_to it. Return the call's return value.
242
254
  #
243
255
  def call_or_send(callable, *args, &block)
244
- return callable.call(self, *args, &block) if callable.respond_to?(:call)
245
- __send__(callable, *args, &block)
256
+ return_value = case
257
+ when callable.respond_to?(:call)
258
+ callable.call(self, *args, &block)
259
+ when respond_to?(callable, true)
260
+ __send__(callable, *args, &block)
261
+ else
262
+ fail "Object #{callable} is not callable"
263
+ end
264
+
265
+ return_value
246
266
  end
267
+
247
268
  end
269
+
248
270
  end
249
271
  end
250
272
  end
@@ -1,3 +1,3 @@
1
1
  module Protobuf
2
- VERSION = '3.6.12'
2
+ VERSION = '3.7.0.pre0'
3
3
  end
@@ -1,6 +1,6 @@
1
1
  // Protocol Buffers - Google's data interchange format
2
2
  // Copyright 2008 Google Inc. All rights reserved.
3
- // http://code.google.com/p/protobuf/
3
+ // https://developers.google.com/protocol-buffers/
4
4
  //
5
5
  // Redistribution and use in source and binary forms, with or without
6
6
  // modification, are permitted provided that the following conditions are
@@ -37,10 +37,14 @@
37
37
  // without any other information (e.g. without reading its imports).
38
38
 
39
39
 
40
+ syntax = "proto2";
40
41
 
41
42
  package google.protobuf;
43
+ option go_package = "descriptor";
42
44
  option java_package = "com.google.protobuf";
43
45
  option java_outer_classname = "DescriptorProtos";
46
+ option csharp_namespace = "Google.Protobuf.Reflection";
47
+ option objc_class_prefix = "GPB";
44
48
 
45
49
  // descriptor.proto must be optimized for speed because reflection-based
46
50
  // algorithms don't work during bootstrapping.
@@ -74,10 +78,14 @@ message FileDescriptorProto {
74
78
  optional FileOptions options = 8;
75
79
 
76
80
  // This field contains optional information about the original source code.
77
- // You may safely remove this entire field whithout harming runtime
81
+ // You may safely remove this entire field without harming runtime
78
82
  // functionality of the descriptors -- the information is needed only by
79
83
  // development tools.
80
84
  optional SourceCodeInfo source_code_info = 9;
85
+
86
+ // The syntax of the proto file.
87
+ // The supported values are "proto2" and "proto3".
88
+ optional string syntax = 12;
81
89
  }
82
90
 
83
91
  // Describes a message type.
@@ -96,7 +104,21 @@ message DescriptorProto {
96
104
  }
97
105
  repeated ExtensionRange extension_range = 5;
98
106
 
107
+ repeated OneofDescriptorProto oneof_decl = 8;
108
+
99
109
  optional MessageOptions options = 7;
110
+
111
+ // Range of reserved tag numbers. Reserved tag numbers may not be used by
112
+ // fields or extension ranges in the same message. Reserved ranges may
113
+ // not overlap.
114
+ message ReservedRange {
115
+ optional int32 start = 1; // Inclusive.
116
+ optional int32 end = 2; // Exclusive.
117
+ }
118
+ repeated ReservedRange reserved_range = 9;
119
+ // Reserved field names, which may not be used by fields in the same message.
120
+ // A given name may only be reserved once.
121
+ repeated string reserved_name = 10;
100
122
  }
101
123
 
102
124
  // Describes a field within a message.
@@ -143,7 +165,7 @@ message FieldDescriptorProto {
143
165
  optional Label label = 4;
144
166
 
145
167
  // If type_name is set, this need not be set. If both this and type_name
146
- // are set, this must be either TYPE_ENUM or TYPE_MESSAGE.
168
+ // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
147
169
  optional Type type = 5;
148
170
 
149
171
  // For message and enum types, this is the name of the type. If the name
@@ -164,9 +186,24 @@ message FieldDescriptorProto {
164
186
  // TODO(kenton): Base-64 encode?
165
187
  optional string default_value = 7;
166
188
 
189
+ // If set, gives the index of a oneof in the containing type's oneof_decl
190
+ // list. This field is a member of that oneof.
191
+ optional int32 oneof_index = 9;
192
+
193
+ // JSON name of this field. The value is set by protocol compiler. If the
194
+ // user has set a "json_name" option on this field, that option's value
195
+ // will be used. Otherwise, it's deduced from the field's name by converting
196
+ // it to camelCase.
197
+ optional string json_name = 10;
198
+
167
199
  optional FieldOptions options = 8;
168
200
  }
169
201
 
202
+ // Describes a oneof.
203
+ message OneofDescriptorProto {
204
+ optional string name = 1;
205
+ }
206
+
170
207
  // Describes an enum type.
171
208
  message EnumDescriptorProto {
172
209
  optional string name = 1;
@@ -202,6 +239,11 @@ message MethodDescriptorProto {
202
239
  optional string output_type = 3;
203
240
 
204
241
  optional MethodOptions options = 4;
242
+
243
+ // Identifies if client streams multiple client messages
244
+ optional bool client_streaming = 5 [default=false];
245
+ // Identifies if server streams multiple server messages
246
+ optional bool server_streaming = 6 [default=false];
205
247
  }
206
248
 
207
249
 
@@ -228,12 +270,12 @@ message MethodDescriptorProto {
228
270
  // * For options which will be published and used publicly by multiple
229
271
  // independent entities, e-mail protobuf-global-extension-registry@google.com
230
272
  // to reserve extension numbers. Simply provide your project name (e.g.
231
- // Object-C plugin) and your porject website (if available) -- there's no need
232
- // to explain how you intend to use them. Usually you only need one extension
233
- // number. You can declare multiple options with only one extension number by
234
- // putting them in a sub-message. See the Custom Options section of the docs
235
- // for examples:
236
- // http://code.google.com/apis/protocolbuffers/docs/proto.html#options
273
+ // Objective-C plugin) and your project website (if available) -- there's no
274
+ // need to explain how you intend to use them. Usually you only need one
275
+ // extension number. You can declare multiple options with only one extension
276
+ // number by putting them in a sub-message. See the Custom Options section of
277
+ // the docs for examples:
278
+ // https://developers.google.com/protocol-buffers/docs/proto#options
237
279
  // If this turns out to be popular, a web service will be set up
238
280
  // to automatically assign option numbers.
239
281
 
@@ -263,11 +305,28 @@ message FileOptions {
263
305
  optional bool java_multiple_files = 10 [default=false];
264
306
 
265
307
  // If set true, then the Java code generator will generate equals() and
266
- // hashCode() methods for all messages defined in the .proto file. This is
267
- // purely a speed optimization, as the AbstractMessage base class includes
268
- // reflection-based implementations of these methods.
308
+ // hashCode() methods for all messages defined in the .proto file.
309
+ // This increases generated code size, potentially substantially for large
310
+ // protos, which may harm a memory-constrained application.
311
+ // - In the full runtime this is a speed optimization, as the
312
+ // AbstractMessage base class includes reflection-based implementations of
313
+ // these methods.
314
+ // - In the lite runtime, setting this option changes the semantics of
315
+ // equals() and hashCode() to more closely match those of the full runtime;
316
+ // the generated methods compute their results based on field values rather
317
+ // than object identity. (Implementations should not assume that hashcodes
318
+ // will be consistent across runtimes or versions of the protocol compiler.)
269
319
  optional bool java_generate_equals_and_hash = 20 [default=false];
270
320
 
321
+ // If set true, then the Java2 code generator will generate code that
322
+ // throws an exception whenever an attempt is made to assign a non-UTF-8
323
+ // byte sequence to a string field.
324
+ // Message reflection will do the same.
325
+ // However, an extension field still accepts non-UTF-8 byte sequences.
326
+ // This option has no effect on when used with the lite runtime.
327
+ optional bool java_string_check_utf8 = 27 [default=false];
328
+
329
+
271
330
  // Generated classes can be optimized for speed or code size.
272
331
  enum OptimizeMode {
273
332
  SPEED = 1; // Generate complete code for parsing, serialization,
@@ -278,7 +337,10 @@ message FileOptions {
278
337
  optional OptimizeMode optimize_for = 9 [default=SPEED];
279
338
 
280
339
  // Sets the Go package where structs generated from this .proto will be
281
- // placed. There is no default.
340
+ // placed. If omitted, the Go package will be derived from the following:
341
+ // - The basename of the package import path, if provided.
342
+ // - Otherwise, the package statement in the .proto file, if present.
343
+ // - Otherwise, the basename of the .proto file, without extension.
282
344
  optional string go_package = 11;
283
345
 
284
346
 
@@ -287,7 +349,7 @@ message FileOptions {
287
349
  // are not specific to any particular RPC system. They are generated by the
288
350
  // main code generators in each language (without additional plugins).
289
351
  // Generic services were the only kind of service generation supported by
290
- // early versions of proto2.
352
+ // early versions of google.protobuf.
291
353
  //
292
354
  // Generic services are now considered deprecated in favor of using plugins
293
355
  // that generate code specific to your particular RPC system. Therefore,
@@ -297,6 +359,28 @@ message FileOptions {
297
359
  optional bool java_generic_services = 17 [default=false];
298
360
  optional bool py_generic_services = 18 [default=false];
299
361
 
362
+ // Is this file deprecated?
363
+ // Depending on the target platform, this can emit Deprecated annotations
364
+ // for everything in the file, or it will be completely ignored; in the very
365
+ // least, this is a formalization for deprecating files.
366
+ optional bool deprecated = 23 [default=false];
367
+
368
+ // Enables the use of arenas for the proto messages in this file. This applies
369
+ // only to generated classes for C++.
370
+ optional bool cc_enable_arenas = 31 [default=false];
371
+
372
+
373
+ // Sets the objective c class prefix which is prepended to all objective c
374
+ // generated classes from this .proto. There is no default.
375
+ optional string objc_class_prefix = 36;
376
+
377
+ // Namespace for generated classes; defaults to the package.
378
+ optional string csharp_namespace = 37;
379
+
380
+ // Whether the nano proto compiler should generate in the deprecated non-nano
381
+ // suffixed package.
382
+ optional bool javanano_use_deprecated_package = 38;
383
+
300
384
  // The parser stores options it doesn't recognize here. See above.
301
385
  repeated UninterpretedOption uninterpreted_option = 999;
302
386
 
@@ -330,6 +414,35 @@ message MessageOptions {
330
414
  // from proto1 easier; new code should avoid fields named "descriptor".
331
415
  optional bool no_standard_descriptor_accessor = 2 [default=false];
332
416
 
417
+ // Is this message deprecated?
418
+ // Depending on the target platform, this can emit Deprecated annotations
419
+ // for the message, or it will be completely ignored; in the very least,
420
+ // this is a formalization for deprecating messages.
421
+ optional bool deprecated = 3 [default=false];
422
+
423
+ // Whether the message is an automatically generated map entry type for the
424
+ // maps field.
425
+ //
426
+ // For maps fields:
427
+ // map<KeyType, ValueType> map_field = 1;
428
+ // The parsed descriptor looks like:
429
+ // message MapFieldEntry {
430
+ // option map_entry = true;
431
+ // optional KeyType key = 1;
432
+ // optional ValueType value = 2;
433
+ // }
434
+ // repeated MapFieldEntry map_field = 1;
435
+ //
436
+ // Implementations may choose not to generate the map_entry=true message, but
437
+ // use a native map in the target language to hold the keys and values.
438
+ // The reflection APIs in such implementions still need to work as
439
+ // if the field is a repeated message field.
440
+ //
441
+ // NOTE: Do not set the option in .proto files. Always use the maps syntax
442
+ // instead. The option should only be implicitly set by the proto compiler
443
+ // parser.
444
+ optional bool map_entry = 7;
445
+
333
446
  // The parser stores options it doesn't recognize here. See above.
334
447
  repeated UninterpretedOption uninterpreted_option = 999;
335
448
 
@@ -354,10 +467,31 @@ message FieldOptions {
354
467
  // The packed option can be enabled for repeated primitive fields to enable
355
468
  // a more efficient representation on the wire. Rather than repeatedly
356
469
  // writing the tag and type for each element, the entire array is encoded as
357
- // a single length-delimited blob.
470
+ // a single length-delimited blob. In proto3, only explicit setting it to
471
+ // false will avoid using packed encoding.
358
472
  optional bool packed = 2;
359
473
 
360
474
 
475
+ // The jstype option determines the JavaScript type used for values of the
476
+ // field. The option is permitted only for 64 bit integral and fixed types
477
+ // (int64, uint64, sint64, fixed64, sfixed64). By default these types are
478
+ // represented as JavaScript strings. This avoids loss of precision that can
479
+ // happen when a large value is converted to a floating point JavaScript
480
+ // numbers. Specifying JS_NUMBER for the jstype causes the generated
481
+ // JavaScript code to use the JavaScript "number" type instead of strings.
482
+ // This option is an enum to permit additional types to be added,
483
+ // e.g. goog.math.Integer.
484
+ optional JSType jstype = 6 [default = JS_NORMAL];
485
+ enum JSType {
486
+ // Use the default type.
487
+ JS_NORMAL = 0;
488
+
489
+ // Use JavaScript strings.
490
+ JS_STRING = 1;
491
+
492
+ // Use JavaScript numbers.
493
+ JS_NUMBER = 2;
494
+ }
361
495
 
362
496
  // Should this field be parsed lazily? Lazy applies only to message-type
363
497
  // fields. It means that when the outer message is initially parsed, the
@@ -395,23 +529,10 @@ message FieldOptions {
395
529
  // is a formalization for deprecating fields.
396
530
  optional bool deprecated = 3 [default=false];
397
531
 
398
- // EXPERIMENTAL. DO NOT USE.
399
- // For "map" fields, the name of the field in the enclosed type that
400
- // is the key for this map. For example, suppose we have:
401
- // message Item {
402
- // required string name = 1;
403
- // required string value = 2;
404
- // }
405
- // message Config {
406
- // repeated Item items = 1 [experimental_map_key="name"];
407
- // }
408
- // In this situation, the map key for Item will be set to "name".
409
- // TODO: Fully-implement this, then remove the "experimental_" prefix.
410
- optional string experimental_map_key = 9;
411
-
412
532
  // For Google-internal migration only. Do not use.
413
533
  optional bool weak = 10 [default=false];
414
534
 
535
+
415
536
  // The parser stores options it doesn't recognize here. See above.
416
537
  repeated UninterpretedOption uninterpreted_option = 999;
417
538
 
@@ -421,9 +542,15 @@ message FieldOptions {
421
542
 
422
543
  message EnumOptions {
423
544
 
424
- // Set this option to false to disallow mapping different tag names to a same
545
+ // Set this option to true to allow mapping different tag names to the same
425
546
  // value.
426
- optional bool allow_alias = 2 [default=true];
547
+ optional bool allow_alias = 2;
548
+
549
+ // Is this enum deprecated?
550
+ // Depending on the target platform, this can emit Deprecated annotations
551
+ // for the enum, or it will be completely ignored; in the very least, this
552
+ // is a formalization for deprecating enums.
553
+ optional bool deprecated = 3 [default=false];
427
554
 
428
555
  // The parser stores options it doesn't recognize here. See above.
429
556
  repeated UninterpretedOption uninterpreted_option = 999;
@@ -433,6 +560,12 @@ message EnumOptions {
433
560
  }
434
561
 
435
562
  message EnumValueOptions {
563
+ // Is this enum value deprecated?
564
+ // Depending on the target platform, this can emit Deprecated annotations
565
+ // for the enum value, or it will be completely ignored; in the very least,
566
+ // this is a formalization for deprecating enum values.
567
+ optional bool deprecated = 1 [default=false];
568
+
436
569
  // The parser stores options it doesn't recognize here. See above.
437
570
  repeated UninterpretedOption uninterpreted_option = 999;
438
571
 
@@ -447,6 +580,12 @@ message ServiceOptions {
447
580
  // we were already using them long before we decided to release Protocol
448
581
  // Buffers.
449
582
 
583
+ // Is this service deprecated?
584
+ // Depending on the target platform, this can emit Deprecated annotations
585
+ // for the service, or it will be completely ignored; in the very least,
586
+ // this is a formalization for deprecating services.
587
+ optional bool deprecated = 33 [default=false];
588
+
450
589
  // The parser stores options it doesn't recognize here. See above.
451
590
  repeated UninterpretedOption uninterpreted_option = 999;
452
591
 
@@ -461,6 +600,12 @@ message MethodOptions {
461
600
  // we were already using them long before we decided to release Protocol
462
601
  // Buffers.
463
602
 
603
+ // Is this method deprecated?
604
+ // Depending on the target platform, this can emit Deprecated annotations
605
+ // for the method, or it will be completely ignored; in the very least,
606
+ // this is a formalization for deprecating methods.
607
+ optional bool deprecated = 33 [default=false];
608
+
464
609
  // The parser stores options it doesn't recognize here. See above.
465
610
  repeated UninterpretedOption uninterpreted_option = 999;
466
611
 
@@ -587,6 +732,11 @@ message SourceCodeInfo {
587
732
  // A series of line comments appearing on consecutive lines, with no other
588
733
  // tokens appearing on those lines, will be treated as a single comment.
589
734
  //
735
+ // leading_detached_comments will keep paragraphs of comments that appear
736
+ // before (but not connected to) the current element. Each paragraph,
737
+ // separated by empty lines, will be one comment element in the repeated
738
+ // field.
739
+ //
590
740
  // Only the comment content is provided; comment markers (e.g. //) are
591
741
  // stripped out. For block comments, leading whitespace and an asterisk
592
742
  // will be stripped from the beginning of each line other than the first.
@@ -607,6 +757,12 @@ message SourceCodeInfo {
607
757
  // // Another line attached to qux.
608
758
  // optional double qux = 4;
609
759
  //
760
+ // // Detached comment for corge. This is not leading or trailing comments
761
+ // // to qux or corge because there are blank lines separating it from
762
+ // // both.
763
+ //
764
+ // // Detached comment for corge paragraph 2.
765
+ //
610
766
  // optional string corge = 5;
611
767
  // /* Block comment attached
612
768
  // * to corge. Leading asterisks
@@ -614,7 +770,10 @@ message SourceCodeInfo {
614
770
  // /* Block comment attached to
615
771
  // * grault. */
616
772
  // optional int32 grault = 6;
773
+ //
774
+ // // ignored detached comments.
617
775
  optional string leading_comments = 3;
618
776
  optional string trailing_comments = 4;
777
+ repeated string leading_detached_comments = 6;
619
778
  }
620
779
  }