protobuf 2.0.0.rc2 → 2.0.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/ext/ruby_generator/Makefile +10 -0
- data/ext/ruby_generator/RubyGenerator.cpp +85 -70
- data/ext/ruby_generator/RubyGenerator.h +23 -4
- data/lib/protobuf.rb +33 -26
- data/lib/protobuf/cli.rb +18 -13
- data/lib/protobuf/enum.rb +39 -34
- data/lib/protobuf/enum_value.rb +29 -0
- data/lib/protobuf/field/base_field.rb +34 -5
- data/lib/protobuf/field/enum_field.rb +6 -14
- data/lib/protobuf/field/extension_fields.rb +13 -5
- data/lib/protobuf/field/field_array.rb +17 -7
- data/lib/protobuf/field/varint_field.rb +4 -6
- data/lib/protobuf/message.rb +44 -148
- data/lib/protobuf/rpc/server.rb +2 -2
- data/lib/protobuf/version.rb +1 -1
- data/spec/benchmark/tasks.rb +7 -8
- data/spec/functional/evented_server_spec.rb +9 -9
- data/spec/functional/socket_server_spec.rb +8 -8
- data/spec/functional/zmq_server_spec.rb +8 -8
- data/spec/lib/protobuf/cli_spec.rb +30 -11
- data/spec/lib/protobuf/enum_spec.rb +90 -0
- data/spec/lib/protobuf/enum_value_spec.rb +13 -0
- data/spec/lib/protobuf/message/encoder_spec.rb +1 -1
- data/spec/lib/protobuf/message_spec.rb +50 -0
- data/spec/lib/protobuf/rpc/client_spec.rb +23 -23
- data/spec/lib/protobuf/rpc/servers/evented_server_spec.rb +1 -1
- data/spec/lib/protobuf/rpc/servers/socket_server_spec.rb +1 -1
- data/spec/lib/protobuf/rpc/service_spec.rb +18 -18
- data/spec/lib/protobuf_spec.rb +62 -0
- data/spec/spec_helper.rb +12 -1
- data/spec/support/all.rb +0 -1
- data/spec/support/server.rb +1 -1
- data/spec/support/test/enum.pb.rb +32 -0
- data/spec/support/test/enum.proto +12 -0
- data/spec/support/test/resource.pb.rb +52 -0
- data/spec/{proto/test.proto → support/test/resource.proto} +2 -2
- data/spec/support/test/resource_service.rb +14 -0
- metadata +51 -48
- data/ext/Makefile +0 -11
- data/spec/lib/protobuf/message/enum_spec.rb +0 -13
- data/spec/lib/protobuf/message/message_spec.rb +0 -67
- data/spec/proto/test.pb.rb +0 -54
- data/spec/proto/test_service.rb +0 -30
- data/spec/proto/test_service_impl.rb +0 -18
- data/spec/support/silent_constants.rb +0 -44
data/.gitignore
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
all: \
|
2
|
+
RubyGenerator.h \
|
3
|
+
RubyGenerator.cpp
|
4
|
+
g++ -Wall -I/code/src/utilities/protobuf-2.4.1/src -lprotoc -lprotobuf -lpthread -o protoc-ruby RubyGenerator.cpp
|
5
|
+
|
6
|
+
test:
|
7
|
+
rm -rf test/out/*
|
8
|
+
./protoc-ruby --proto_path=../defs --ruby_out=../out ../defs/atlas/util.proto ../defs/atlas/newman/*.proto
|
9
|
+
|
10
|
+
.PHONY: all test
|
@@ -42,9 +42,7 @@ bool RubyGenerator::Generate(const FileDescriptor* file,
|
|
42
42
|
PrintNewLine();
|
43
43
|
|
44
44
|
PrintEnumsForFileDescriptor(file_, true);
|
45
|
-
PrintNewLine();
|
46
45
|
PrintMessagesForFileDescriptor(file_, true);
|
47
|
-
PrintNewLine();
|
48
46
|
|
49
47
|
PrintServices();
|
50
48
|
|
@@ -100,60 +98,42 @@ void RubyGenerator::PrintMessagesForFileDescriptor(const FileDescriptor* descrip
|
|
100
98
|
}
|
101
99
|
|
102
100
|
for (int i = 0; i < descriptor->message_type_count(); i++) {
|
103
|
-
|
104
|
-
PrintMessageFields(descriptor->message_type(i));
|
105
|
-
}
|
106
|
-
else {
|
107
|
-
PrintMessageClass(descriptor->message_type(i));
|
108
|
-
}
|
101
|
+
PrintMessage(descriptor->message_type(i), print_fields);
|
109
102
|
}
|
110
103
|
}
|
111
104
|
}
|
112
105
|
|
113
106
|
void RubyGenerator::PrintMessagesForDescriptor(const Descriptor* descriptor, bool print_fields) const {
|
114
107
|
for (int i = 0; i < descriptor->nested_type_count(); i++) {
|
115
|
-
|
116
|
-
PrintMessageFields(descriptor->nested_type(i));
|
117
|
-
}
|
118
|
-
else {
|
119
|
-
PrintMessageClass(descriptor->nested_type(i));
|
120
|
-
}
|
108
|
+
PrintMessage(descriptor->nested_type(i), print_fields);
|
121
109
|
}
|
122
110
|
}
|
123
111
|
//
|
124
112
|
// Print out the given descriptor message as a Ruby class.
|
125
|
-
void RubyGenerator::
|
113
|
+
void RubyGenerator::PrintMessage(const Descriptor* descriptor, bool print_fields) const {
|
126
114
|
map<string,string> data;
|
127
115
|
data["class_name"] = descriptor->name();
|
128
116
|
|
129
|
-
|
130
|
-
|
117
|
+
if (print_fields) {
|
118
|
+
printer_->Print(data, "class $class_name$");
|
119
|
+
PrintNewLine();
|
120
|
+
printer_->Indent();
|
131
121
|
|
132
|
-
|
133
|
-
|
134
|
-
}
|
122
|
+
if (descriptor->enum_type_count() > 0) {
|
123
|
+
PrintEnumsForDescriptor(descriptor, true);
|
124
|
+
}
|
135
125
|
|
136
|
-
|
137
|
-
|
138
|
-
for (int i = 0; i < descriptor->extension_range_count(); i++) {
|
139
|
-
const Descriptor::ExtensionRange* range = descriptor->extension_range(i);
|
140
|
-
map<string,string> data;
|
141
|
-
data["message_class"] = Constantize(descriptor->full_name());
|
142
|
-
data["start"] = SimpleItoa(range->start);
|
143
|
-
data["end"] = SimpleItoa(range->end);
|
144
|
-
printer_->Print(data, "$message_class$.extensions $start$...$end$");
|
145
|
-
PrintNewLine();
|
126
|
+
if (descriptor->nested_type_count() > 0) {
|
127
|
+
PrintMessagesForDescriptor(descriptor, true);
|
146
128
|
}
|
147
|
-
}
|
148
|
-
}
|
149
129
|
|
150
|
-
|
151
|
-
void RubyGenerator::PrintMessageFields(const Descriptor* descriptor) const {
|
152
|
-
PrintExtensionRangesForDescriptor(descriptor);
|
130
|
+
PrintExtensionRangesForDescriptor(descriptor);
|
153
131
|
|
154
|
-
|
155
|
-
|
156
|
-
|
132
|
+
// Print Fields
|
133
|
+
if (descriptor->field_count() > 0) {
|
134
|
+
for (int i = 0; i < descriptor->field_count(); i++) {
|
135
|
+
PrintMessageField(descriptor->field(i));
|
136
|
+
}
|
157
137
|
}
|
158
138
|
|
159
139
|
// Print Extension Fields
|
@@ -162,17 +142,53 @@ void RubyGenerator::PrintMessageFields(const Descriptor* descriptor) const {
|
|
162
142
|
PrintMessageField(descriptor->extension(i));
|
163
143
|
}
|
164
144
|
}
|
145
|
+
|
146
|
+
printer_->Outdent();
|
147
|
+
printer_->Print(data, "end");
|
165
148
|
PrintNewLine();
|
166
149
|
}
|
150
|
+
else if (DescriptorHasNestedTypes(descriptor)) {
|
151
|
+
printer_->Print(data, "class $class_name$ < ::Protobuf::Message");
|
152
|
+
PrintNewLine();
|
153
|
+
printer_->Indent();
|
154
|
+
|
155
|
+
if (descriptor->enum_type_count() > 0) {
|
156
|
+
PrintEnumsForDescriptor(descriptor, false);
|
157
|
+
}
|
158
|
+
|
159
|
+
if (descriptor->nested_type_count() > 0) {
|
160
|
+
PrintMessagesForDescriptor(descriptor, false);
|
161
|
+
}
|
167
162
|
|
168
|
-
|
169
|
-
|
163
|
+
printer_->Outdent();
|
164
|
+
printer_->Print(data, "end");
|
165
|
+
PrintNewLine();
|
166
|
+
}
|
167
|
+
else {
|
168
|
+
printer_->Print(data, "class $class_name$ < ::Protobuf::Message; end");
|
169
|
+
}
|
170
|
+
|
171
|
+
PrintNewLine();
|
172
|
+
}
|
173
|
+
|
174
|
+
void RubyGenerator::PrintExtensionRangesForDescriptor(const Descriptor* descriptor) const {
|
175
|
+
if (descriptor->extension_range_count() > 0) {
|
176
|
+
for (int i = 0; i < descriptor->extension_range_count(); i++) {
|
177
|
+
const Descriptor::ExtensionRange* range = descriptor->extension_range(i);
|
178
|
+
map<string,string> data;
|
179
|
+
data["message_class"] = Constantize(descriptor->full_name());
|
180
|
+
data["start"] = SimpleItoa(range->start);
|
181
|
+
data["end"] = SimpleItoa(range->end);
|
182
|
+
printer_->Print(data, "extensions $start$...$end$");
|
183
|
+
PrintNewLine();
|
184
|
+
}
|
185
|
+
}
|
170
186
|
}
|
171
187
|
|
172
188
|
// Print the given FieldDescriptor to the Message DSL methods.
|
173
189
|
void RubyGenerator::PrintMessageField(const FieldDescriptor* descriptor) const {
|
174
190
|
map<string,string> data;
|
175
|
-
data["
|
191
|
+
data["field_presence"] = "";
|
176
192
|
data["field_name"] = descriptor->lowercase_name();
|
177
193
|
data["tag_number"] = SimpleItoa(descriptor->number());
|
178
194
|
data["data_type"] = "";
|
@@ -182,13 +198,13 @@ void RubyGenerator::PrintMessageField(const FieldDescriptor* descriptor) const {
|
|
182
198
|
data["extension_opt"] = "";
|
183
199
|
|
184
200
|
if (descriptor->is_required()) {
|
185
|
-
data["
|
201
|
+
data["field_presence"] = "required";
|
186
202
|
}
|
187
203
|
else if (descriptor->is_optional()) {
|
188
|
-
data["
|
204
|
+
data["field_presence"] = "optional";
|
189
205
|
}
|
190
206
|
else if (descriptor->is_repeated()) {
|
191
|
-
data["
|
207
|
+
data["field_presence"] = "repeated";
|
192
208
|
}
|
193
209
|
|
194
210
|
switch (descriptor->type()) {
|
@@ -232,7 +248,7 @@ void RubyGenerator::PrintMessageField(const FieldDescriptor* descriptor) const {
|
|
232
248
|
case FieldDescriptor::CPPTYPE_DOUBLE: value = SimpleDtoa(descriptor->default_value_double()); break;
|
233
249
|
case FieldDescriptor::CPPTYPE_FLOAT: value = SimpleFtoa(descriptor->default_value_float()); break;
|
234
250
|
case FieldDescriptor::CPPTYPE_BOOL: value = descriptor->default_value_bool() ? "true" : "false"; break;
|
235
|
-
case FieldDescriptor::CPPTYPE_ENUM: value =
|
251
|
+
case FieldDescriptor::CPPTYPE_ENUM: value = FullEnumNamespace(descriptor->default_value_enum()); break;
|
236
252
|
case FieldDescriptor::CPPTYPE_STRING: value = "\"" + descriptor->default_value_string() + "\""; break;
|
237
253
|
default: break;
|
238
254
|
}
|
@@ -254,15 +270,15 @@ void RubyGenerator::PrintMessageField(const FieldDescriptor* descriptor) const {
|
|
254
270
|
}
|
255
271
|
|
256
272
|
printer_->Print(data,
|
257
|
-
"$
|
273
|
+
"$field_presence$ "
|
258
274
|
"$data_type$, "
|
259
275
|
":$field_name$, "
|
260
276
|
"$tag_number$"
|
261
277
|
"$default_opt$"
|
262
278
|
"$packed_opt$"
|
263
279
|
"$deprecated_opt$"
|
264
|
-
"$extension_opt$"
|
265
|
-
|
280
|
+
"$extension_opt$");
|
281
|
+
PrintNewLine();
|
266
282
|
}
|
267
283
|
|
268
284
|
|
@@ -272,12 +288,7 @@ void RubyGenerator::PrintMessageField(const FieldDescriptor* descriptor) const {
|
|
272
288
|
|
273
289
|
void RubyGenerator::PrintEnumsForDescriptor(const Descriptor* descriptor, bool print_values) const {
|
274
290
|
for (int i = 0; i < descriptor->enum_type_count(); i++) {
|
275
|
-
|
276
|
-
PrintEnumValues(descriptor->enum_type(i));
|
277
|
-
}
|
278
|
-
else {
|
279
|
-
PrintEnumClass(descriptor->enum_type(i));
|
280
|
-
}
|
291
|
+
PrintEnum(descriptor->enum_type(i), print_values);
|
281
292
|
}
|
282
293
|
}
|
283
294
|
|
@@ -291,39 +302,43 @@ void RubyGenerator::PrintEnumsForFileDescriptor(const FileDescriptor* descriptor
|
|
291
302
|
}
|
292
303
|
|
293
304
|
for (int i = 0; i < descriptor->enum_type_count(); i++) {
|
294
|
-
|
295
|
-
PrintEnumValues(descriptor->enum_type(i));
|
296
|
-
}
|
297
|
-
else {
|
298
|
-
PrintEnumClass(descriptor->enum_type(i));
|
299
|
-
}
|
305
|
+
PrintEnum(descriptor->enum_type(i), print_values);
|
300
306
|
}
|
301
307
|
}
|
302
308
|
}
|
303
309
|
|
304
310
|
// Print the given enum descriptor as a Ruby class.
|
305
|
-
void RubyGenerator::
|
311
|
+
void RubyGenerator::PrintEnum(const EnumDescriptor* descriptor, bool print_values) const {
|
306
312
|
map<string,string> data;
|
307
313
|
data["class_name"] = descriptor->name();
|
308
|
-
printer_->Print(data, "class $class_name$ < ::Protobuf::Enum; end");
|
309
|
-
PrintNewLine();
|
310
|
-
}
|
311
314
|
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
315
|
+
if (print_values) {
|
316
|
+
printer_->Print(data, "class $class_name$");
|
317
|
+
printer_->Indent();
|
318
|
+
PrintNewLine();
|
319
|
+
|
320
|
+
for (int i = 0; i < descriptor->value_count(); i++) {
|
321
|
+
PrintEnumValue(descriptor->value(i));
|
322
|
+
}
|
323
|
+
|
324
|
+
printer_->Outdent();
|
325
|
+
printer_->Print(data, "end");
|
326
|
+
PrintNewLine();
|
316
327
|
}
|
328
|
+
else {
|
329
|
+
printer_->Print(data, "class $class_name$ < ::Protobuf::Enum; end");
|
330
|
+
}
|
331
|
+
|
317
332
|
PrintNewLine();
|
318
333
|
}
|
319
334
|
|
320
335
|
// Print the given enum value to the Enum class DSL methods.
|
321
336
|
void RubyGenerator::PrintEnumValue(const EnumValueDescriptor* descriptor) const {
|
322
337
|
map<string,string> data;
|
323
|
-
data["enum_class"] = Constantize(descriptor->type()->full_name());
|
324
338
|
data["name"] = descriptor->name();
|
325
339
|
data["number"] = ConvertIntToString(descriptor->number());
|
326
|
-
printer_->Print(data, "
|
340
|
+
printer_->Print(data, "define :$name$, $number$");
|
341
|
+
PrintNewLine();
|
327
342
|
}
|
328
343
|
|
329
344
|
//
|
@@ -46,15 +46,13 @@ class LIBPROTOC_EXPORT RubyGenerator : public CodeGenerator {
|
|
46
46
|
|
47
47
|
void PrintMessagesForDescriptor(const Descriptor* descriptor, bool print_fields) const;
|
48
48
|
void PrintMessagesForFileDescriptor(const FileDescriptor* descriptor, bool print_fields) const;
|
49
|
-
void
|
49
|
+
void PrintMessage(const Descriptor* descriptor, bool print_fields) const;
|
50
50
|
void PrintExtensionRangesForDescriptor(const Descriptor* descriptor) const;
|
51
|
-
void PrintMessageFields(const Descriptor* descriptor) const;
|
52
51
|
void PrintMessageField(const FieldDescriptor* descriptor) const;
|
53
52
|
|
54
53
|
void PrintEnumsForDescriptor(const Descriptor* descriptor, bool print_values) const;
|
55
54
|
void PrintEnumsForFileDescriptor(const FileDescriptor* descriptor, bool print_values) const;
|
56
|
-
void
|
57
|
-
void PrintEnumValues(const EnumDescriptor* descriptor) const;
|
55
|
+
void PrintEnum(const EnumDescriptor* descriptor, bool print_values) const;
|
58
56
|
void PrintEnumValue(const EnumValueDescriptor* descriptor) const;
|
59
57
|
|
60
58
|
void PrintServices() const;
|
@@ -152,6 +150,17 @@ class LIBPROTOC_EXPORT RubyGenerator : public CodeGenerator {
|
|
152
150
|
return underscored.str();
|
153
151
|
}
|
154
152
|
|
153
|
+
static string FullEnumNamespace(const EnumValueDescriptor* descriptor) {
|
154
|
+
string parent_enum_type = Constantize(descriptor->type()->full_name());
|
155
|
+
string enum_name = descriptor->name();
|
156
|
+
|
157
|
+
return strings::Substitute("$0::$1", parent_enum_type, enum_name);
|
158
|
+
}
|
159
|
+
|
160
|
+
static bool DescriptorHasNestedTypes(const Descriptor* descriptor) {
|
161
|
+
return (descriptor->enum_type_count() > 0 || descriptor->nested_type_count() > 0);
|
162
|
+
}
|
163
|
+
|
155
164
|
}; // class RubyGenerator
|
156
165
|
|
157
166
|
} // namespace ruby
|
@@ -173,6 +182,16 @@ int _rprotoc_extern(int argc, char* argv[]) {
|
|
173
182
|
return cli.Run(argc, argv);
|
174
183
|
}
|
175
184
|
|
185
|
+
/*
|
186
|
+
|
187
|
+
Use for testing:
|
188
|
+
|
189
|
+
int main(int argc, char* argv[]) {
|
190
|
+
return _rprotoc_extern(argc, argv);
|
191
|
+
}
|
192
|
+
|
193
|
+
*/
|
194
|
+
|
176
195
|
#ifdef __cplusplus
|
177
196
|
}
|
178
197
|
#endif
|
data/lib/protobuf.rb
CHANGED
@@ -14,13 +14,31 @@ module Protobuf
|
|
14
14
|
|
15
15
|
module_function
|
16
16
|
|
17
|
+
# Connector Type
|
18
|
+
#
|
19
|
+
# Default: socket
|
20
|
+
#
|
21
|
+
# Symbol value which denotes the type of connector to use
|
22
|
+
# during client requests to an RPC server.
|
23
|
+
def self.connector_type
|
24
|
+
@_connector_type ||= DEFAULT_CONNECTOR_TYPE
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.connector_type=(type)
|
28
|
+
raise ArgumentError, 'Invalid connector type given' unless VALID_CONNECTOR_TYPES.include?(type)
|
29
|
+
@_connector_type = type
|
30
|
+
end
|
31
|
+
|
32
|
+
|
17
33
|
# GC Pause during server requests
|
18
34
|
#
|
35
|
+
# Default: false
|
36
|
+
#
|
19
37
|
# Boolean value to tell the server to disable
|
20
38
|
# the Garbage Collector when handling an rpc request.
|
21
39
|
# Once the request is completed, the GC is enabled again.
|
22
40
|
# This optomization provides a huge boost in speed to rpc requests.
|
23
|
-
def self.gc_pause_server_request
|
41
|
+
def self.gc_pause_server_request?
|
24
42
|
return @_gc_pause_server_request unless @_gc_pause_server_request.nil?
|
25
43
|
gc_pause_server_request = false
|
26
44
|
end
|
@@ -29,36 +47,25 @@ module Protobuf
|
|
29
47
|
@_gc_pause_server_request = !!value
|
30
48
|
end
|
31
49
|
|
32
|
-
#
|
50
|
+
# Print Deprecation Warnings
|
33
51
|
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
|
41
|
-
|
42
|
-
|
52
|
+
# Default: true
|
53
|
+
#
|
54
|
+
# Simple boolean to define whether we want field deprecation warnings to
|
55
|
+
# be printed to stderr or not. The rpc_server has an option to set this value
|
56
|
+
# explicitly, or you can turn this option off by setting
|
57
|
+
# ENV['PB_IGNORE_DEPRECATIONS'] to a non-empty value.
|
58
|
+
#
|
59
|
+
# The rpc_server option will override the ENV setting.
|
60
|
+
def self.print_deprecation_warnings?
|
61
|
+
return @_print_deprecation_warnings unless @_print_deprecation_warnings.nil?
|
62
|
+
print_deprecation_warnings = ENV.key?('PB_IGNORE_DEPRECATIONS') ? false : true
|
43
63
|
end
|
44
64
|
|
45
|
-
def self.
|
46
|
-
@
|
65
|
+
def self.print_deprecation_warnings=(value)
|
66
|
+
@_print_deprecation_warnings = !!value
|
47
67
|
end
|
48
68
|
|
49
|
-
# Connector Type
|
50
|
-
#
|
51
|
-
# Symbol value which denotes the type of connector to use
|
52
|
-
# during client requests to an RPC server.
|
53
|
-
def self.connector_type
|
54
|
-
@_connector_type ||= DEFAULT_CONNECTOR_TYPE
|
55
|
-
end
|
56
|
-
|
57
|
-
def self.connector_type=(type)
|
58
|
-
raise 'Invalid connector type given' unless VALID_CONNECTOR_TYPES.include?(type)
|
59
|
-
@_connector_type = type
|
60
|
-
end
|
61
|
-
|
62
69
|
end
|
63
70
|
|
64
71
|
require 'protobuf/rpc/client'
|
data/lib/protobuf/cli.rb
CHANGED
@@ -16,22 +16,22 @@ module Protobuf
|
|
16
16
|
|
17
17
|
desc 'start APP_FILE', 'Run the RPC server in the given mode, preloading the given APP_FILE. This is the default task.'
|
18
18
|
|
19
|
-
option :host,
|
20
|
-
option :port,
|
19
|
+
option :host, :type => :string, :default => '127.0.0.1', :aliases => %w(-o), :desc => 'Host to bind.'
|
20
|
+
option :port, :type => :numeric, :default => 9595, :aliases => %w(-p), :desc => 'Port to bind.'
|
21
21
|
|
22
|
-
option :backlog,
|
23
|
-
option :threshold,
|
22
|
+
option :backlog, :type => :numeric, :default => 100, :aliases => %w(-b), :desc => 'Backlog for listening socket when using Socket Server.'
|
23
|
+
option :threshold, :type => :numeric, :default => 100, :aliases => %w(-t), :desc => 'Multi-threaded Socket Server cleanup threshold.'
|
24
24
|
|
25
|
-
option :log,
|
26
|
-
option :level,
|
25
|
+
option :log, :type => :string, :aliases => %w(-l), :desc => 'Log file or device. Default is STDOUT.'
|
26
|
+
option :level, :type => :numeric, :default => ::Logger::INFO, :aliases => %w(-v), :desc => 'Log level to use, 0-5 (see http://www.ruby-doc.org/stdlib/libdoc/logger/rdoc/)'
|
27
27
|
|
28
|
-
option :socket,
|
29
|
-
option :evented,
|
30
|
-
option :zmq,
|
28
|
+
option :socket, :type => :boolean, :aliases => %w(-s), :desc => 'Socket Mode for server and client connections.'
|
29
|
+
option :evented, :type => :boolean, :aliases => %w(-m), :desc => 'Evented Mode for server and client connections (uses EventMachine).'
|
30
|
+
option :zmq, :type => :boolean, :aliases => %w(-z), :desc => 'ZeroMQ Socket Mode for server and client connections.'
|
31
31
|
|
32
|
-
option :debug,
|
33
|
-
option :gc_pause_request,
|
34
|
-
option :
|
32
|
+
option :debug, :type => :boolean, :default => false, :aliases => %w(-d), :desc => 'Debug Mode. Override log level to DEBUG.'
|
33
|
+
option :gc_pause_request, :type => :boolean, :default => false, :desc => 'Enable/Disable GC pause during request.'
|
34
|
+
option :print_deprecation_warnings, :type => :boolean, :default => true, :desc => 'Cause use of deprecated fields to be printed or ignored.'
|
35
35
|
|
36
36
|
def start(app_file)
|
37
37
|
debug_say 'Configuring the rpc_server process'
|
@@ -42,6 +42,7 @@ module Protobuf
|
|
42
42
|
configure_server_mode
|
43
43
|
require_protobuf!
|
44
44
|
configure_gc
|
45
|
+
configure_deprecation_warnings
|
45
46
|
|
46
47
|
run_if_no_abort { require_application!(app_file) }
|
47
48
|
run_if_no_abort { configure_process_name(app_file) }
|
@@ -58,11 +59,15 @@ module Protobuf
|
|
58
59
|
|
59
60
|
no_tasks do
|
60
61
|
|
62
|
+
# Tell protobuf how to handle the printing of deprecated field usage.
|
63
|
+
def configure_deprecation_warnings
|
64
|
+
::Protobuf.print_deprecation_warnings = options.print_deprecation_warnings?
|
65
|
+
end
|
66
|
+
|
61
67
|
# If we pause during request we don't need to pause in serialization
|
62
68
|
def configure_gc
|
63
69
|
debug_say 'Configuring gc'
|
64
70
|
::Protobuf.gc_pause_server_request = options.gc_pause_request?
|
65
|
-
::Protobuf.gc_pause_server_serialization = (!options.gc_pause_request? && options.gc_pause_serialization?)
|
66
71
|
end
|
67
72
|
|
68
73
|
# Setup the protobuf logger.
|