protobuf 3.10.1 → 3.10.5

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: 8631e0e157cd16a50b428ca4888a48d8b294002e1844beca975db88c696038ed
4
- data.tar.gz: 9111c88f5b491c625155ce1ee683f0462778a3b7ae9e49671333275e9829bca0
3
+ metadata.gz: 3e3465827a6baf50d8cb30a689bd13858d7423390f2cb0405929e494578bac2a
4
+ data.tar.gz: 88b6210d9bbe3323a8b7f81e3c3d6f5d3c6cb404637a31fe04ff57a6bb2a4c2e
5
5
  SHA512:
6
- metadata.gz: bb3d3ee59579cb21771885ebd0ee7bda1e0aa09736cfc15b3053ca9b6206769b5e4eaa2ea8b8ad4d3fb77a85b0dfc985cd69012bda90c0ee23d8e673aed6e373
7
- data.tar.gz: feb9889203fa3fc6d33c6efeb74fe8a22ccca41af5bb1f3e15f517ce0a1b8fff07b5a1145117f056dbd5a314498ea70851240dd77969fd7b82742b700e5d1bea
6
+ metadata.gz: 2d84ed2d0d670143cf9d59e664a7ad3e50ad8e0f1293594f5784f249e63b81e5d9ebfe55d1defbc8b1c058333b6faba72e217929dec752dedf87a58758310941
7
+ data.tar.gz: 5119bb0a3370b04323883962b6f8bd56c9c319a95155e83793bbc69d7879b1a75923e2e4c3164593adddd0aaceda7e18031a07b9badc0562ded3b698a1f4d481
@@ -0,0 +1,48 @@
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/jruby:9.2-jdk8
46
+ - circleci/ruby:2.4
47
+ - circleci/ruby:2.5
48
+ - 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',
data/lib/protobuf/cli.rb CHANGED
@@ -240,6 +240,8 @@ module Protobuf
240
240
  def start_server
241
241
  debug_say('Running server')
242
242
 
243
+ ::ActiveSupport::Notifications.instrument("before_server_bind")
244
+
243
245
  runner.run do
244
246
  logger.info do
245
247
  "pid #{::Process.pid} -- #{mode} RPC Server listening at #{options.host}:#{options.port}"
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Protobuf
2
- VERSION = '3.10.1' # rubocop:disable Style/MutableConstant
2
+ VERSION = '3.10.5' # rubocop:disable Style/MutableConstant
3
3
  end
data/lib/protobuf.rb CHANGED
@@ -54,6 +54,18 @@ module Protobuf
54
54
  attr_writer :client_host
55
55
  end
56
56
 
57
+ def self.after_server_bind(&block)
58
+ ::ActiveSupport::Notifications.subscribe('after_server_bind') do |*args|
59
+ block.call(*args)
60
+ end
61
+ end
62
+
63
+ def self.before_server_bind(&block)
64
+ ::ActiveSupport::Notifications.subscribe('before_server_bind') do |*args|
65
+ block.call(*args)
66
+ end
67
+ end
68
+
57
69
  def self.client_host
58
70
  @client_host ||= Socket.gethostname
59
71
  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
  }