protobuf 3.10.3 → 3.10.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b525441c3875b1c480aa66d017320f94e6a1709dc57a01a00046875dc818514b
4
- data.tar.gz: b0120b20ec1992adb4aae4f257bc3f3e019c0cd928b1f11b716ff3443aff22d2
3
+ metadata.gz: 4ea13b6353fc56a116dc91e87662ffaaac8c4b8cb27dd85be480797e7ef922d2
4
+ data.tar.gz: 6f5804860b80527356f1a6cec79def05499abd4a5536038c453e7e65cd05c237
5
5
  SHA512:
6
- metadata.gz: '08c01a3a8158ffec5621d563a298e6cce89044dcac4a1ffbc64f40fd792efc29fe960e76527e2b3fbdbfefa0bb464d51b576c9ec0dcc54aa71d444ef104c7e14'
7
- data.tar.gz: c980ad847a3f546792925141738373ca511ed42ae161e37b4447f7b109e9fea1a6697241951a89faff0e1871bcc6f0b42fb47eac5d36f9af37bc3c0b8f2433d3
6
+ metadata.gz: a49491b32df80049107f59673008d6f8ac64977abcae332ad407c120f9f9628f4c3b47dbd5f809b8843ce477e02286da3fc1242131a8919ddac7170e2002bbf4
7
+ data.tar.gz: b5352584a6c79b77ce1360fb0ce6a03c00a165cdfb8f92b96aaf61d37a3acf7a89f7bd4bd2fc8a3f1c879434b941db3e0689040edf5988cee2c05cb5bfd0a3a5
@@ -0,0 +1,46 @@
1
+ version: 2.1
2
+
3
+ jobs:
4
+ # skipping build step because Gemfile.lock is not included in the source
5
+ # this makes the bundler caching step a noop
6
+ test:
7
+ parameters:
8
+ ruby-image:
9
+ type: string
10
+ docker:
11
+ - image: << parameters.ruby-image >>
12
+ steps:
13
+ - run:
14
+ name: Install protobuf compiler
15
+ command: |
16
+ archive=protoc-3.16.0-linux-x86_64
17
+ curl -O -L https://github.com/protocolbuffers/protobuf/releases/download/v3.16.0/$archive.zip
18
+ sudo unzip -d '/usr/local' $archive.zip 'bin/*' 'include/*'
19
+ sudo chown -R $(whoami) /usr/local/bin/protoc /usr/local/include/google
20
+ rm -rf $archive.zip
21
+ - run:
22
+ command: protoc --version
23
+ - run:
24
+ command: sudo apt-get update
25
+ - run:
26
+ message: Install ZeroMQ
27
+ command: sudo apt-get -y install libzmq3-dev
28
+ - checkout
29
+ - run:
30
+ command: gem install bundler
31
+ - run:
32
+ command: bundle install
33
+ - run:
34
+ command: bundle exec rake
35
+
36
+ workflows:
37
+ build_and_test:
38
+ jobs:
39
+ - test:
40
+ matrix:
41
+ parameters:
42
+ ruby-image:
43
+ - circleci/jruby:9.2.6.0-jdk
44
+ - circleci/jruby:9.1.17.0-jdk
45
+ - circleci/ruby:2.5
46
+ - circleci/ruby:2.7
data/CHANGES.md CHANGED
@@ -4,6 +4,7 @@
4
4
  3.10.0
5
5
  ------
6
6
  - Add headers to request proto
7
+ - Add support for compiling v3 protos with optional fields as v2 optional fields
7
8
 
8
9
  3.9.0
9
10
  -----
data/Rakefile CHANGED
@@ -22,10 +22,12 @@ namespace :compile do
22
22
  task :spec do
23
23
  proto_path = ::File.expand_path('../spec/support/', __FILE__)
24
24
  proto_files = Dir[File.join(proto_path, '**', '*.proto')]
25
- cmd = %(protoc --plugin=./bin/protoc-gen-ruby --ruby_out=#{proto_path} -I #{proto_path} #{proto_files.join(' ')})
26
25
 
27
- puts cmd
28
- system(cmd)
26
+ proto_files.each do |proto_file|
27
+ cmd = %(protoc --plugin=protoc-gen-ruby-protobuf=./bin/protoc-gen-ruby --ruby-protobuf_out=#{proto_path} -I #{proto_path} #{proto_file})
28
+ puts cmd
29
+ system(cmd) || fail("Failed to compile spec proto: #{proto_file}")
30
+ end
29
31
  end
30
32
 
31
33
  desc 'Compile rpc protos in protos/ directory'
@@ -35,10 +37,10 @@ namespace :compile do
35
37
  output_dir = ::File.expand_path('../tmp/rpc', __FILE__)
36
38
  ::FileUtils.mkdir_p(output_dir)
37
39
 
38
- cmd = %(protoc --plugin=./bin/protoc-gen-ruby --ruby_out=#{output_dir} -I #{proto_path} #{proto_files.join(' ')})
40
+ cmd = %(protoc --plugin=protoc-gen-ruby-protobuf=./bin/protoc-gen-ruby --ruby-protobuf_out=#{output_dir} -I #{proto_path} #{proto_files.join(' ')})
39
41
 
40
42
  puts cmd
41
- system(cmd)
43
+ system(cmd) || fail("Failed to compile rpc protos!")
42
44
 
43
45
  files = {
44
46
  'tmp/rpc/dynamic_discovery.pb.rb' => 'lib/protobuf/rpc',
@@ -46,7 +46,16 @@ module Protobuf
46
46
  generate_file(file_descriptor)
47
47
  end
48
48
 
49
- ::Google::Protobuf::Compiler::CodeGeneratorResponse.encode(:file => generated_files)
49
+ ::Google::Protobuf::Compiler::CodeGeneratorResponse.encode(
50
+ :file => generated_files,
51
+ :supported_features => supported_features,
52
+ )
53
+ end
54
+
55
+ def supported_features
56
+ # The only available feature is proto3 with optional fields.
57
+ # This is backwards compatible with proto2 optional fields.
58
+ ::Google::Protobuf::Compiler::CodeGeneratorResponse::Feature::FEATURE_PROTO3_OPTIONAL.to_i
50
59
  end
51
60
 
52
61
  Protobuf::Field::BaseField.module_eval do
@@ -19,8 +19,14 @@ module Google
19
19
  ##
20
20
  # Message Classes
21
21
  #
22
+ class Version < ::Protobuf::Message; end
22
23
  class CodeGeneratorRequest < ::Protobuf::Message; end
23
24
  class CodeGeneratorResponse < ::Protobuf::Message
25
+ class Feature < ::Protobuf::Enum
26
+ define :FEATURE_NONE, 0
27
+ define :FEATURE_PROTO3_OPTIONAL, 1
28
+ end
29
+
24
30
  class File < ::Protobuf::Message; end
25
31
 
26
32
  end
@@ -32,15 +38,24 @@ module Google
32
38
  #
33
39
  set_option :java_package, "com.google.protobuf.compiler"
34
40
  set_option :java_outer_classname, "PluginProtos"
41
+ set_option :go_package, "google.golang.org/protobuf/types/pluginpb"
35
42
 
36
43
 
37
44
  ##
38
45
  # Message Fields
39
46
  #
47
+ class Version
48
+ optional :int32, :major, 1
49
+ optional :int32, :minor, 2
50
+ optional :int32, :patch, 3
51
+ optional :string, :suffix, 4
52
+ end
53
+
40
54
  class CodeGeneratorRequest
41
55
  repeated :string, :file_to_generate, 1
42
56
  optional :string, :parameter, 2
43
57
  repeated ::Google::Protobuf::FileDescriptorProto, :proto_file, 15
58
+ optional ::Google::Protobuf::Compiler::Version, :compiler_version, 3
44
59
  end
45
60
 
46
61
  class CodeGeneratorResponse
@@ -48,9 +63,11 @@ module Google
48
63
  optional :string, :name, 1
49
64
  optional :string, :insertion_point, 2
50
65
  optional :string, :content, 15
66
+ optional ::Google::Protobuf::GeneratedCodeInfo, :generated_code_info, 16
51
67
  end
52
68
 
53
69
  optional :string, :error, 1
70
+ optional :uint64, :supported_features, 2
54
71
  repeated ::Google::Protobuf::Compiler::CodeGeneratorResponse::File, :file, 15
55
72
  end
56
73
 
@@ -20,6 +20,7 @@ module Google
20
20
 
21
21
  end
22
22
 
23
+ class ExtensionRangeOptions < ::Protobuf::Message; end
23
24
  class FieldDescriptorProto < ::Protobuf::Message
24
25
  class Type < ::Protobuf::Enum
25
26
  define :TYPE_DOUBLE, 1
@@ -51,7 +52,11 @@ module Google
51
52
  end
52
53
 
53
54
  class OneofDescriptorProto < ::Protobuf::Message; end
54
- class EnumDescriptorProto < ::Protobuf::Message; end
55
+ class EnumDescriptorProto < ::Protobuf::Message
56
+ class EnumReservedRange < ::Protobuf::Message; end
57
+
58
+ end
59
+
55
60
  class EnumValueDescriptorProto < ::Protobuf::Message; end
56
61
  class ServiceDescriptorProto < ::Protobuf::Message; end
57
62
  class MethodDescriptorProto < ::Protobuf::Message; end
@@ -80,10 +85,19 @@ module Google
80
85
 
81
86
  end
82
87
 
88
+ class OneofOptions < ::Protobuf::Message; end
83
89
  class EnumOptions < ::Protobuf::Message; end
84
90
  class EnumValueOptions < ::Protobuf::Message; end
85
91
  class ServiceOptions < ::Protobuf::Message; end
86
- class MethodOptions < ::Protobuf::Message; end
92
+ class MethodOptions < ::Protobuf::Message
93
+ class IdempotencyLevel < ::Protobuf::Enum
94
+ define :IDEMPOTENCY_UNKNOWN, 0
95
+ define :NO_SIDE_EFFECTS, 1
96
+ define :IDEMPOTENT, 2
97
+ end
98
+
99
+ end
100
+
87
101
  class UninterpretedOption < ::Protobuf::Message
88
102
  class NamePart < ::Protobuf::Message; end
89
103
 
@@ -94,6 +108,11 @@ module Google
94
108
 
95
109
  end
96
110
 
111
+ class GeneratedCodeInfo < ::Protobuf::Message
112
+ class Annotation < ::Protobuf::Message; end
113
+
114
+ end
115
+
97
116
 
98
117
 
99
118
  ##
@@ -102,7 +121,8 @@ module Google
102
121
  set_option :java_package, "com.google.protobuf"
103
122
  set_option :java_outer_classname, "DescriptorProtos"
104
123
  set_option :optimize_for, ::Google::Protobuf::FileOptions::OptimizeMode::SPEED
105
- set_option :go_package, "descriptor"
124
+ set_option :go_package, "google.golang.org/protobuf/types/descriptorpb"
125
+ set_option :cc_enable_arenas, true
106
126
  set_option :objc_class_prefix, "GPB"
107
127
  set_option :csharp_namespace, "Google.Protobuf.Reflection"
108
128
 
@@ -133,6 +153,7 @@ module Google
133
153
  class ExtensionRange
134
154
  optional :int32, :start, 1
135
155
  optional :int32, :end, 2
156
+ optional ::Google::Protobuf::ExtensionRangeOptions, :options, 3
136
157
  end
137
158
 
138
159
  class ReservedRange
@@ -152,6 +173,12 @@ module Google
152
173
  repeated :string, :reserved_name, 10
153
174
  end
154
175
 
176
+ class ExtensionRangeOptions
177
+ repeated ::Google::Protobuf::UninterpretedOption, :uninterpreted_option, 999
178
+ # Extension Fields
179
+ extensions 1000...536870912
180
+ end
181
+
155
182
  class FieldDescriptorProto
156
183
  optional :string, :name, 1
157
184
  optional :int32, :number, 3
@@ -163,16 +190,25 @@ module Google
163
190
  optional :int32, :oneof_index, 9
164
191
  optional :string, :json_name, 10
165
192
  optional ::Google::Protobuf::FieldOptions, :options, 8
193
+ optional :bool, :proto3_optional, 17
166
194
  end
167
195
 
168
196
  class OneofDescriptorProto
169
197
  optional :string, :name, 1
198
+ optional ::Google::Protobuf::OneofOptions, :options, 2
170
199
  end
171
200
 
172
201
  class EnumDescriptorProto
202
+ class EnumReservedRange
203
+ optional :int32, :start, 1
204
+ optional :int32, :end, 2
205
+ end
206
+
173
207
  optional :string, :name, 1
174
208
  repeated ::Google::Protobuf::EnumValueDescriptorProto, :value, 2
175
209
  optional ::Google::Protobuf::EnumOptions, :options, 3
210
+ repeated ::Google::Protobuf::EnumDescriptorProto::EnumReservedRange, :reserved_range, 4
211
+ repeated :string, :reserved_name, 5
176
212
  end
177
213
 
178
214
  class EnumValueDescriptorProto
@@ -200,18 +236,23 @@ module Google
200
236
  optional :string, :java_package, 1
201
237
  optional :string, :java_outer_classname, 8
202
238
  optional :bool, :java_multiple_files, 10, :default => false
203
- optional :bool, :java_generate_equals_and_hash, 20, :default => false
239
+ optional :bool, :java_generate_equals_and_hash, 20, :deprecated => true
204
240
  optional :bool, :java_string_check_utf8, 27, :default => false
205
241
  optional ::Google::Protobuf::FileOptions::OptimizeMode, :optimize_for, 9, :default => ::Google::Protobuf::FileOptions::OptimizeMode::SPEED
206
242
  optional :string, :go_package, 11
207
243
  optional :bool, :cc_generic_services, 16, :default => false
208
244
  optional :bool, :java_generic_services, 17, :default => false
209
245
  optional :bool, :py_generic_services, 18, :default => false
246
+ optional :bool, :php_generic_services, 42, :default => false
210
247
  optional :bool, :deprecated, 23, :default => false
211
- optional :bool, :cc_enable_arenas, 31, :default => false
248
+ optional :bool, :cc_enable_arenas, 31, :default => true
212
249
  optional :string, :objc_class_prefix, 36
213
250
  optional :string, :csharp_namespace, 37
214
- optional :bool, :javanano_use_deprecated_package, 38
251
+ optional :string, :swift_prefix, 39
252
+ optional :string, :php_class_prefix, 40
253
+ optional :string, :php_namespace, 41
254
+ optional :string, :php_metadata_namespace, 44
255
+ optional :string, :ruby_package, 45
215
256
  repeated ::Google::Protobuf::UninterpretedOption, :uninterpreted_option, 999
216
257
  # Extension Fields
217
258
  extensions 1000...536870912
@@ -239,6 +280,12 @@ module Google
239
280
  extensions 1000...536870912
240
281
  end
241
282
 
283
+ class OneofOptions
284
+ repeated ::Google::Protobuf::UninterpretedOption, :uninterpreted_option, 999
285
+ # Extension Fields
286
+ extensions 1000...536870912
287
+ end
288
+
242
289
  class EnumOptions
243
290
  optional :bool, :allow_alias, 2
244
291
  optional :bool, :deprecated, 3, :default => false
@@ -263,6 +310,7 @@ module Google
263
310
 
264
311
  class MethodOptions
265
312
  optional :bool, :deprecated, 33, :default => false
313
+ optional ::Google::Protobuf::MethodOptions::IdempotencyLevel, :idempotency_level, 34, :default => ::Google::Protobuf::MethodOptions::IdempotencyLevel::IDEMPOTENCY_UNKNOWN
266
314
  repeated ::Google::Protobuf::UninterpretedOption, :uninterpreted_option, 999
267
315
  # Extension Fields
268
316
  extensions 1000...536870912
@@ -295,6 +343,17 @@ module Google
295
343
  repeated ::Google::Protobuf::SourceCodeInfo::Location, :location, 1
296
344
  end
297
345
 
346
+ class GeneratedCodeInfo
347
+ class Annotation
348
+ repeated :int32, :path, 1, :packed => true
349
+ optional :string, :source_file, 2
350
+ optional :int32, :begin, 3
351
+ optional :int32, :end, 4
352
+ end
353
+
354
+ repeated ::Google::Protobuf::GeneratedCodeInfo::Annotation, :annotation, 1
355
+ end
356
+
298
357
  end
299
358
 
300
359
  end
@@ -13,12 +13,12 @@ module Protobuf
13
13
  super message
14
14
  end
15
15
 
16
- def encode
17
- to_response.encode
16
+ def encode(args = {})
17
+ to_response(args).encode
18
18
  end
19
19
 
20
- def to_response
21
- ::Protobuf::Socketrpc::Response.new(:error => message, :error_reason => error_type)
20
+ def to_response(args = {})
21
+ ::Protobuf::Socketrpc::Response.new({ :error => message, :error_reason => error_type }.merge(args))
22
22
  end
23
23
  end
24
24
  end
@@ -22,7 +22,7 @@ module Protobuf
22
22
  # Rescue exceptions, re-wrap them as generic Protobuf errors,
23
23
  # and encode them
24
24
  env.response = wrap_exception(exception)
25
- env.encoded_response = env.response.encode
25
+ env.encoded_response = wrap_and_encode_with_server(env.response, env)
26
26
  env
27
27
  end
28
28
 
@@ -34,6 +34,17 @@ module Protobuf
34
34
  exception = RpcFailed.new(exception.message) unless exception.is_a?(PbError)
35
35
  exception
36
36
  end
37
+
38
+ # If the response is a PbError, it won't have the server merged into the response proto.
39
+ # We should add it here since exception handler is always at the bottom of the middleware
40
+ # stack. Without this, the server hostname in the client rpc log will not be set.
41
+ def wrap_and_encode_with_server(response, env)
42
+ if response.is_a?(PbError)
43
+ response.encode(:server => env.server)
44
+ else
45
+ response.encode
46
+ end
47
+ end
37
48
  end
38
49
  end
39
50
  end
@@ -1,3 +1,3 @@
1
1
  module Protobuf
2
- VERSION = '3.10.3' # rubocop:disable Style/MutableConstant
2
+ VERSION = '3.10.6' # rubocop:disable Style/MutableConstant
3
3
  end
@@ -22,6 +22,8 @@
22
22
  //
23
23
  // Protobufs needed for dynamic discovery zmq server and client.
24
24
 
25
+ syntax = "proto2";
26
+
25
27
  package protobuf.rpc.dynamicDiscovery;
26
28
 
27
29
  enum BeaconType {
@@ -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
@@ -44,12 +44,26 @@
44
44
  // plugin should be named "protoc-gen-$NAME", and will then be used when the
45
45
  // flag "--${NAME}_out" is passed to protoc.
46
46
 
47
+ syntax = "proto2";
48
+
47
49
  package google.protobuf.compiler;
48
50
  option java_package = "com.google.protobuf.compiler";
49
51
  option java_outer_classname = "PluginProtos";
50
52
 
53
+ option go_package = "google.golang.org/protobuf/types/pluginpb";
54
+
51
55
  import "google/protobuf/descriptor.proto";
52
56
 
57
+ // The version number of protocol compiler.
58
+ message Version {
59
+ optional int32 major = 1;
60
+ optional int32 minor = 2;
61
+ optional int32 patch = 3;
62
+ // A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should
63
+ // be empty for mainline stable releases.
64
+ optional string suffix = 4;
65
+ }
66
+
53
67
  // An encoded CodeGeneratorRequest is written to the plugin's stdin.
54
68
  message CodeGeneratorRequest {
55
69
  // The .proto files that were explicitly listed on the command-line. The
@@ -71,7 +85,14 @@ message CodeGeneratorRequest {
71
85
  // the entire set into memory at once. However, as of this writing, this
72
86
  // is not similarly optimized on protoc's end -- it will store all fields in
73
87
  // memory at once before sending them to the plugin.
88
+ //
89
+ // Type names of fields and extensions in the FileDescriptorProto are always
90
+ // fully qualified.
74
91
  repeated FileDescriptorProto proto_file = 15;
92
+
93
+ // The version number of protocol compiler.
94
+ optional Version compiler_version = 3;
95
+
75
96
  }
76
97
 
77
98
  // The plugin writes an encoded CodeGeneratorResponse to stdout.
@@ -86,6 +107,16 @@ message CodeGeneratorResponse {
86
107
  // exiting with a non-zero status code.
87
108
  optional string error = 1;
88
109
 
110
+ // A bitmask of supported features that the code generator supports.
111
+ // This is a bitwise "or" of values from the Feature enum.
112
+ optional uint64 supported_features = 2;
113
+
114
+ // Sync with code_generator.h.
115
+ enum Feature {
116
+ FEATURE_NONE = 0;
117
+ FEATURE_PROTO3_OPTIONAL = 1;
118
+ }
119
+
89
120
  // Represents a single generated file.
90
121
  message File {
91
122
  // The file name, relative to the output directory. The name must not
@@ -142,6 +173,11 @@ message CodeGeneratorResponse {
142
173
 
143
174
  // The file contents.
144
175
  optional string content = 15;
176
+
177
+ // Information describing the file content being inserted. If an insertion
178
+ // point is used, this information will be appropriately offset and inserted
179
+ // into the code generation metadata for the generated files.
180
+ optional GeneratedCodeInfo generated_code_info = 16;
145
181
  }
146
182
  repeated File file = 15;
147
183
  }