contrast-agent 6.3.0 → 6.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -3
  3. data/.simplecov +1 -0
  4. data/Rakefile +0 -27
  5. data/lib/contrast/agent/assess/policy/propagation_method.rb +0 -2
  6. data/lib/contrast/agent/assess/policy/trigger_method.rb +1 -1
  7. data/lib/contrast/agent/version.rb +1 -1
  8. data/lib/contrast/api/dtm.pb.rb +1 -1
  9. data/lib/contrast/api/settings.pb.rb +1 -1
  10. data/lib/contrast/utils/patching/policy/patch_utils.rb +5 -22
  11. data/lib/contrast.rb +34 -0
  12. data/lib/protobuf/code_generator.rb +129 -0
  13. data/lib/protobuf/decoder.rb +28 -0
  14. data/lib/protobuf/deprecation.rb +117 -0
  15. data/lib/protobuf/descriptors/google/protobuf/compiler/plugin.pb.rb +79 -0
  16. data/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb +360 -0
  17. data/lib/protobuf/descriptors.rb +3 -0
  18. data/lib/protobuf/encoder.rb +11 -0
  19. data/lib/protobuf/enum.rb +365 -0
  20. data/lib/protobuf/exceptions.rb +9 -0
  21. data/lib/protobuf/field/base_field.rb +380 -0
  22. data/lib/protobuf/field/base_field_object_definitions.rb +504 -0
  23. data/lib/protobuf/field/bool_field.rb +64 -0
  24. data/lib/protobuf/field/bytes_field.rb +67 -0
  25. data/lib/protobuf/field/double_field.rb +25 -0
  26. data/lib/protobuf/field/enum_field.rb +56 -0
  27. data/lib/protobuf/field/field_array.rb +102 -0
  28. data/lib/protobuf/field/field_hash.rb +122 -0
  29. data/lib/protobuf/field/fixed32_field.rb +25 -0
  30. data/lib/protobuf/field/fixed64_field.rb +28 -0
  31. data/lib/protobuf/field/float_field.rb +43 -0
  32. data/lib/protobuf/field/int32_field.rb +21 -0
  33. data/lib/protobuf/field/int64_field.rb +34 -0
  34. data/lib/protobuf/field/integer_field.rb +23 -0
  35. data/lib/protobuf/field/message_field.rb +51 -0
  36. data/lib/protobuf/field/sfixed32_field.rb +27 -0
  37. data/lib/protobuf/field/sfixed64_field.rb +28 -0
  38. data/lib/protobuf/field/signed_integer_field.rb +29 -0
  39. data/lib/protobuf/field/sint32_field.rb +21 -0
  40. data/lib/protobuf/field/sint64_field.rb +21 -0
  41. data/lib/protobuf/field/string_field.rb +51 -0
  42. data/lib/protobuf/field/uint32_field.rb +21 -0
  43. data/lib/protobuf/field/uint64_field.rb +21 -0
  44. data/lib/protobuf/field/varint_field.rb +77 -0
  45. data/lib/protobuf/field.rb +74 -0
  46. data/lib/protobuf/generators/base.rb +85 -0
  47. data/lib/protobuf/generators/enum_generator.rb +39 -0
  48. data/lib/protobuf/generators/extension_generator.rb +27 -0
  49. data/lib/protobuf/generators/field_generator.rb +193 -0
  50. data/lib/protobuf/generators/file_generator.rb +262 -0
  51. data/lib/protobuf/generators/group_generator.rb +122 -0
  52. data/lib/protobuf/generators/message_generator.rb +104 -0
  53. data/lib/protobuf/generators/option_generator.rb +17 -0
  54. data/lib/protobuf/generators/printable.rb +160 -0
  55. data/lib/protobuf/generators/service_generator.rb +50 -0
  56. data/lib/protobuf/lifecycle.rb +33 -0
  57. data/lib/protobuf/logging.rb +39 -0
  58. data/lib/protobuf/message/fields.rb +233 -0
  59. data/lib/protobuf/message/serialization.rb +85 -0
  60. data/lib/protobuf/message.rb +241 -0
  61. data/lib/protobuf/optionable.rb +72 -0
  62. data/lib/protobuf/tasks/compile.rake +80 -0
  63. data/lib/protobuf/tasks.rb +1 -0
  64. data/lib/protobuf/varint.rb +20 -0
  65. data/lib/protobuf/varint_pure.rb +31 -0
  66. data/lib/protobuf/version.rb +3 -0
  67. data/lib/protobuf/wire_type.rb +10 -0
  68. data/lib/protobuf.rb +91 -0
  69. data/proto/dynamic_discovery.proto +46 -0
  70. data/proto/google/protobuf/compiler/plugin.proto +183 -0
  71. data/proto/google/protobuf/descriptor.proto +911 -0
  72. data/proto/rpc.proto +71 -0
  73. data/ruby-agent.gemspec +1 -1
  74. metadata +71 -10
@@ -0,0 +1,72 @@
1
+ require 'active_support/core_ext/object/try'
2
+
3
+ module Protobuf
4
+ module Optionable
5
+ module ClassMethods
6
+ def get_option(name)
7
+ name = name.to_s
8
+ option = optionable_descriptor_class.get_field(name, true)
9
+ fail ArgumentError, "invalid option=#{name}" unless option
10
+ unless option.fully_qualified_name.to_s == name
11
+ # Eventually we'll deprecate the use of simple names of fields completely, but for now make sure people
12
+ # are accessing options correctly. We allow simple names in other places for backwards compatibility.
13
+ fail ArgumentError, "must access option using its fully qualified name: #{option.fully_qualified_name.inspect}"
14
+ end
15
+ value =
16
+ if @_optionable_options.try(:key?, name)
17
+ @_optionable_options[name]
18
+ else
19
+ option.default_value
20
+ end
21
+ if option.type_class < ::Protobuf::Message
22
+ option.type_class.new(value)
23
+ else
24
+ value
25
+ end
26
+ end
27
+
28
+ def get_option!(name)
29
+ get_option(name) if @_optionable_options.try(:key?, name.to_s)
30
+ end
31
+
32
+ private
33
+
34
+ def set_option(name, value = true)
35
+ @_optionable_options ||= {}
36
+ @_optionable_options[name.to_s] = value
37
+ end
38
+ end
39
+
40
+ def get_option(name)
41
+ self.class.get_option(name)
42
+ end
43
+
44
+ def get_option!(name)
45
+ self.class.get_option!(name)
46
+ end
47
+
48
+ def self.inject(base_class, extend_class = true, &block)
49
+ unless block_given?
50
+ fail ArgumentError, 'missing option class block (e.g: ::CSGoogle::Protobuf::MessageOptions)'
51
+ end
52
+ if extend_class
53
+ # Check if optionable_descriptor_class is already defined and short circuit if so.
54
+ # File options are injected per module, and since a module can be defined more than once,
55
+ # we will get a warning if we try to define optionable_descriptor_class twice.
56
+ if base_class.respond_to?(:optionable_descriptor_class)
57
+ # Don't define optionable_descriptor_class twice
58
+ return if base_class.optionable_descriptor_class == block.call
59
+
60
+ fail 'A class is being defined with two different descriptor classes, something is very wrong'
61
+ end
62
+
63
+ base_class.extend(ClassMethods)
64
+ base_class.__send__(:include, self)
65
+ base_class.define_singleton_method(:optionable_descriptor_class, block)
66
+ else
67
+ base_class.__send__(:include, ClassMethods)
68
+ base_class.module_eval { define_method(:optionable_descriptor_class, block) }
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,80 @@
1
+ require "fileutils"
2
+
3
+ namespace :protobuf do
4
+
5
+ desc "Clean & Compile the protobuf source to ruby classes. Pass PB_NO_CLEAN=1 if you do not want to force-clean first."
6
+ task :compile, [:package, :source, :destination, :plugin, :file_extension] do |_tasks, args|
7
+ binpath = ::File.expand_path("../../../../bin", __FILE__)
8
+
9
+ args.with_defaults(:destination => "lib")
10
+ args.with_defaults(:source => "definitions")
11
+ args.with_defaults(:plugin => "protoc-gen-ruby-protobuf=#{binpath}/protoc-gen-ruby")
12
+ args.with_defaults(:file_extension => ".pb.rb")
13
+
14
+ # The local Ruby generator collides with the builtin Ruby generator
15
+ #
16
+ # From the protoc docs:
17
+ #
18
+ # --plugin=EXECUTABLE
19
+ #
20
+ # ...EXECUTABLE may be of the form NAME=PATH, in which case the given plugin name
21
+ # is mapped to the given executable even if the executable"s own name differs.
22
+ #
23
+ # Use the NAME=PATH form to specify an alternative plugin name that avoids the name collision
24
+ #
25
+ plugin_name, _plugin_path = args[:plugin].split("=")
26
+
27
+ # The plugin name MUST have the protoc-gen- prefix in order to work, but that prefix is dropped
28
+ # when using the plugin to generate definitions
29
+ plugin_name.gsub!("protoc-gen-", "")
30
+
31
+ unless do_not_clean?
32
+ force_clean!
33
+ ::Rake::Task[:clean].invoke(args[:package], args[:destination], args[:file_extension])
34
+ end
35
+
36
+ command = []
37
+ command << "protoc"
38
+ command << "--plugin=#{args[:plugin]}"
39
+ command << "--#{plugin_name}_out=#{args[:destination]}"
40
+ command << "-I #{args[:source]}"
41
+ command << Dir["#{args[:source]}/#{args[:package]}/**/*.proto"].join(" ")
42
+ full_command = command.join(" ")
43
+
44
+ puts full_command
45
+ system(full_command)
46
+ end
47
+
48
+ desc "Clean the generated *.pb.rb files from the destination package. Pass PB_FORCE_CLEAN=1 to skip confirmation step."
49
+ task :clean, [:package, :destination, :file_extension] do |_task, args|
50
+ args.with_defaults(:destination => "lib")
51
+ args.with_defaults(:file_extension => ".pb.rb")
52
+
53
+ file_extension = args[:file_extension].sub(/\*?\.+/, "")
54
+ files_to_clean = ::File.join(args[:destination], args[:package], "**", "*.#{file_extension}")
55
+
56
+ if force_clean? || permission_to_clean?(files_to_clean)
57
+ ::Dir.glob(files_to_clean).each do |file|
58
+ ::FileUtils.rm(file)
59
+ end
60
+ end
61
+ end
62
+
63
+ def do_not_clean?
64
+ ! ::ENV.key?("PB_NO_CLEAN")
65
+ end
66
+
67
+ def force_clean?
68
+ ::ENV.key?("PB_FORCE_CLEAN")
69
+ end
70
+
71
+ def force_clean!
72
+ ::ENV["PB_FORCE_CLEAN"] = "1"
73
+ end
74
+
75
+ def permission_to_clean?(files_to_clean)
76
+ puts "Do you really want to remove files matching pattern #{files_to_clean}? (y/n)"
77
+ ::STDIN.gets.chomp =~ /y(es)?/i
78
+ end
79
+
80
+ end
@@ -0,0 +1 @@
1
+ load 'protobuf/tasks/compile.rake'
@@ -0,0 +1,20 @@
1
+ module Protobuf
2
+ class Varint
3
+ if defined?(::Varint)
4
+ extend ::Varint
5
+
6
+ def self.encode(value)
7
+ bytes = []
8
+ until value < 128
9
+ bytes << (0x80 | (value & 0x7f))
10
+ value >>= 7
11
+ end
12
+ (bytes << value).pack('C*')
13
+ end
14
+ elsif defined?(::ProtobufJavaHelpers)
15
+ extend ::ProtobufJavaHelpers::EncodeDecode
16
+ else
17
+ extend VarintPure
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,31 @@
1
+ module Protobuf
2
+ module VarintPure
3
+ CACHE_LIMIT = 2048
4
+
5
+ def cached_varint(value)
6
+ @_varint_cache ||= {}
7
+ (@_varint_cache[value] ||= encode(value, false)).dup
8
+ end
9
+
10
+ def decode(stream)
11
+ value = index = 0
12
+ begin
13
+ byte = stream.readbyte
14
+ value |= (byte & 0x7f) << (7 * index)
15
+ index += 1
16
+ end while (byte & 0x80).nonzero?
17
+ value
18
+ end
19
+
20
+ def encode(value, use_cache = true)
21
+ return cached_varint(value) if use_cache && value >= 0 && value <= CACHE_LIMIT
22
+
23
+ bytes = []
24
+ until value < 128
25
+ bytes << (0x80 | (value & 0x7f))
26
+ value >>= 7
27
+ end
28
+ (bytes << value).pack('C*')
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,3 @@
1
+ module Protobuf
2
+ VERSION = '3.10.6' # rubocop:disable Style/MutableConstant
3
+ end
@@ -0,0 +1,10 @@
1
+ module Protobuf
2
+ module WireType
3
+ VARINT = 0
4
+ FIXED64 = 1
5
+ LENGTH_DELIMITED = 2
6
+ START_GROUP = 3
7
+ END_GROUP = 4
8
+ FIXED32 = 5
9
+ end
10
+ end
data/lib/protobuf.rb ADDED
@@ -0,0 +1,91 @@
1
+ require 'base64'
2
+ require 'logger'
3
+ require 'pp'
4
+ require 'socket'
5
+ require 'stringio'
6
+
7
+ # All top-level run time code requires, ordered by necessity
8
+ require 'protobuf/wire_type'
9
+
10
+ require 'protobuf/varint_pure'
11
+ require 'protobuf/varint'
12
+
13
+ require 'protobuf/exceptions'
14
+ require 'protobuf/deprecation'
15
+ require 'protobuf/logging'
16
+
17
+ require 'protobuf/encoder'
18
+ require 'protobuf/decoder'
19
+
20
+ require 'protobuf/optionable'
21
+ require 'protobuf/field'
22
+ require 'protobuf/enum'
23
+ require 'protobuf/message'
24
+ require 'protobuf/descriptors'
25
+
26
+ module Protobuf
27
+ class << self
28
+ # Client Host
29
+ #
30
+ # Default: `hostname` of the system
31
+ #
32
+ # The name or address of the host to use during client RPC calls.
33
+ attr_writer :client_host
34
+ end
35
+
36
+ def self.after_server_bind
37
+ ::ActiveSupport::Notifications.subscribe('after_server_bind') do |*args|
38
+ yield(*args)
39
+ end
40
+ end
41
+
42
+ def self.before_server_bind
43
+ ::ActiveSupport::Notifications.subscribe('before_server_bind') do |*args|
44
+ yield(*args)
45
+ end
46
+ end
47
+
48
+ def self.client_host
49
+ @client_host ||= Socket.gethostname
50
+ end
51
+
52
+ def self.connector_type_class
53
+ @connector_type_class ||= ::Protobuf::Rpc::Connectors::Socket
54
+ end
55
+
56
+ def self.connector_type_class= type_class
57
+ @connector_type_class = type_class
58
+ end
59
+
60
+ # GC Pause during server requests
61
+ #
62
+ # Default: false
63
+ #
64
+ # Boolean value to tell the server to disable
65
+ # the Garbage Collector when handling an rpc request.
66
+ # Once the request is completed, the GC is enabled again.
67
+ # This optomization provides a huge boost in speed to rpc requests.
68
+ def self.gc_pause_server_request?
69
+ return @gc_pause_server_request unless @gc_pause_server_request.nil?
70
+
71
+ self.gc_pause_server_request = false
72
+ end
73
+
74
+ def self.gc_pause_server_request= value
75
+ @gc_pause_server_request = !!value
76
+ end
77
+
78
+ # Permit unknown field on Message initialization
79
+ #
80
+ # Default: true
81
+ #
82
+ # Simple boolean to define whether we want to permit unknown fields
83
+ # on Message intialization; otherwise a ::Protobuf::FieldNotDefinedError is thrown.
84
+ def self.ignore_unknown_fields?
85
+ !defined?(@ignore_unknown_fields) || @ignore_unknown_fields
86
+ end
87
+
88
+ def self.ignore_unknown_fields= value
89
+ @ignore_unknown_fields = !!value
90
+ end
91
+ end
@@ -0,0 +1,46 @@
1
+ // Copyright (c) 2013 MoneyDesktop, Inc.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ // of this software and associated documentation files (the "Software"), to deal
5
+ // in the Software without restriction, including without limitation the rights
6
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ // copies of the Software, and to permit persons to whom the Software is
8
+ // furnished to do so, subject to the following conditions:
9
+ //
10
+ // The above copyright notice and this permission notice shall be included in
11
+ // all copies or substantial portions of the Software.
12
+ //
13
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ // THE SOFTWARE.
20
+
21
+ // Authors: Devin Christensen
22
+ //
23
+ // Protobufs needed for dynamic discovery zmq server and client.
24
+
25
+ syntax = "proto2";
26
+
27
+ package protobuf.rpc.dynamicDiscovery;
28
+
29
+ enum BeaconType {
30
+ HEARTBEAT = 0;
31
+ FLATLINE = 1;
32
+ }
33
+
34
+ message Server {
35
+ optional string uuid = 1;
36
+ optional string address = 2;
37
+ optional string port = 3;
38
+ optional int32 ttl = 4;
39
+ repeated string services = 5;
40
+ }
41
+
42
+ message Beacon {
43
+ optional BeaconType beacon_type = 1;
44
+ optional Server server = 2;
45
+ }
46
+
@@ -0,0 +1,183 @@
1
+ // Protocol Buffers - Google's data interchange format
2
+ // Copyright 2008 Google Inc. All rights reserved.
3
+ // https://developers.google.com/protocol-buffers/
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
+ //
33
+ // WARNING: The plugin interface is currently EXPERIMENTAL and is subject to
34
+ // change.
35
+ //
36
+ // protoc (aka the Protocol Compiler) can be extended via plugins. A plugin is
37
+ // just a program that reads a CodeGeneratorRequest from stdin and writes a
38
+ // CodeGeneratorResponse to stdout.
39
+ //
40
+ // Plugins written using C++ can use google/protobuf/compiler/plugin.h instead
41
+ // of dealing with the raw protocol defined here.
42
+ //
43
+ // A plugin executable needs only to be placed somewhere in the path. The
44
+ // plugin should be named "protoc-gen-$NAME", and will then be used when the
45
+ // flag "--${NAME}_out" is passed to protoc.
46
+
47
+ syntax = "proto2";
48
+
49
+ package google.protobuf.compiler;
50
+ option java_package = "com.google.protobuf.compiler";
51
+ option java_outer_classname = "PluginProtos";
52
+
53
+ option go_package = "google.golang.org/protobuf/types/pluginpb";
54
+
55
+ import "google/protobuf/descriptor.proto";
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
+
67
+ // An encoded CodeGeneratorRequest is written to the plugin's stdin.
68
+ message CodeGeneratorRequest {
69
+ // The .proto files that were explicitly listed on the command-line. The
70
+ // code generator should generate code only for these files. Each file's
71
+ // descriptor will be included in proto_file, below.
72
+ repeated string file_to_generate = 1;
73
+
74
+ // The generator parameter passed on the command-line.
75
+ optional string parameter = 2;
76
+
77
+ // FileDescriptorProtos for all files in files_to_generate and everything
78
+ // they import. The files will appear in topological order, so each file
79
+ // appears before any file that imports it.
80
+ //
81
+ // protoc guarantees that all proto_files will be written after
82
+ // the fields above, even though this is not technically guaranteed by the
83
+ // protobuf wire format. This theoretically could allow a plugin to stream
84
+ // in the FileDescriptorProtos and handle them one by one rather than read
85
+ // the entire set into memory at once. However, as of this writing, this
86
+ // is not similarly optimized on protoc's end -- it will store all fields in
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.
91
+ repeated FileDescriptorProto proto_file = 15;
92
+
93
+ // The version number of protocol compiler.
94
+ optional Version compiler_version = 3;
95
+
96
+ }
97
+
98
+ // The plugin writes an encoded CodeGeneratorResponse to stdout.
99
+ message CodeGeneratorResponse {
100
+ // Error message. If non-empty, code generation failed. The plugin process
101
+ // should exit with status code zero even if it reports an error in this way.
102
+ //
103
+ // This should be used to indicate errors in .proto files which prevent the
104
+ // code generator from generating correct code. Errors which indicate a
105
+ // problem in protoc itself -- such as the input CodeGeneratorRequest being
106
+ // unparseable -- should be reported by writing a message to stderr and
107
+ // exiting with a non-zero status code.
108
+ optional string error = 1;
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
+
120
+ // Represents a single generated file.
121
+ message File {
122
+ // The file name, relative to the output directory. The name must not
123
+ // contain "." or ".." components and must be relative, not be absolute (so,
124
+ // the file cannot lie outside the output directory). "/" must be used as
125
+ // the path separator, not "\".
126
+ //
127
+ // If the name is omitted, the content will be appended to the previous
128
+ // file. This allows the generator to break large files into small chunks,
129
+ // and allows the generated text to be streamed back to protoc so that large
130
+ // files need not reside completely in memory at one time. Note that as of
131
+ // this writing protoc does not optimize for this -- it will read the entire
132
+ // CodeGeneratorResponse before writing files to disk.
133
+ optional string name = 1;
134
+
135
+ // If non-empty, indicates that the named file should already exist, and the
136
+ // content here is to be inserted into that file at a defined insertion
137
+ // point. This feature allows a code generator to extend the output
138
+ // produced by another code generator. The original generator may provide
139
+ // insertion points by placing special annotations in the file that look
140
+ // like:
141
+ // @@protoc_insertion_point(NAME)
142
+ // The annotation can have arbitrary text before and after it on the line,
143
+ // which allows it to be placed in a comment. NAME should be replaced with
144
+ // an identifier naming the point -- this is what other generators will use
145
+ // as the insertion_point. Code inserted at this point will be placed
146
+ // immediately above the line containing the insertion point (thus multiple
147
+ // insertions to the same point will come out in the order they were added).
148
+ // The double-@ is intended to make it unlikely that the generated code
149
+ // could contain things that look like insertion points by accident.
150
+ //
151
+ // For example, the C++ code generator places the following line in the
152
+ // .pb.h files that it generates:
153
+ // // @@protoc_insertion_point(namespace_scope)
154
+ // This line appears within the scope of the file's package namespace, but
155
+ // outside of any particular class. Another plugin can then specify the
156
+ // insertion_point "namespace_scope" to generate additional classes or
157
+ // other declarations that should be placed in this scope.
158
+ //
159
+ // Note that if the line containing the insertion point begins with
160
+ // whitespace, the same whitespace will be added to every line of the
161
+ // inserted text. This is useful for languages like Python, where
162
+ // indentation matters. In these languages, the insertion point comment
163
+ // should be indented the same amount as any inserted code will need to be
164
+ // in order to work correctly in that context.
165
+ //
166
+ // The code generator that generates the initial file and the one which
167
+ // inserts into it must both run as part of a single invocation of protoc.
168
+ // Code generators are executed in the order in which they appear on the
169
+ // command line.
170
+ //
171
+ // If |insertion_point| is present, |name| must also be present.
172
+ optional string insertion_point = 2;
173
+
174
+ // The file contents.
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;
181
+ }
182
+ repeated File file = 15;
183
+ }