protobuf 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile.lock +23 -30
- data/bin/rpc_server +23 -6
- data/lib/protobuf/message/enum.rb +1 -1
- data/lib/protobuf/message/field.rb +15 -27
- data/lib/protobuf/message/message.rb +106 -44
- data/lib/protobuf/rpc/server.rb +16 -0
- data/lib/protobuf/rpc/servers/socket_runner.rb +5 -5
- data/lib/protobuf/rpc/servers/zmq/worker.rb +1 -2
- data/lib/protobuf/version.rb +1 -1
- data/spec/unit/common/logger_spec.rb +2 -2
- data/spec/unit/rpc/client_spec.rb +1 -1
- metadata +22 -22
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
protobuf (1.
|
4
|
+
protobuf (1.4.0)
|
5
5
|
eventmachine
|
6
6
|
eventually
|
7
7
|
ffi-rzmq
|
@@ -10,46 +10,39 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: http://rubygems.org/
|
12
12
|
specs:
|
13
|
-
coderay (1.0.
|
13
|
+
coderay (1.0.7)
|
14
14
|
diff-lcs (1.1.3)
|
15
|
-
eventmachine (0.
|
15
|
+
eventmachine (1.0.0)
|
16
16
|
eventually (0.1.1)
|
17
|
-
ffi (1.
|
18
|
-
ffi-rzmq (0.9.
|
17
|
+
ffi (1.1.5)
|
18
|
+
ffi-rzmq (0.9.6)
|
19
19
|
ffi
|
20
|
-
json_pure (1.7.
|
21
|
-
method_source (0.
|
22
|
-
multi_json (1.
|
23
|
-
pry (0.9.
|
20
|
+
json_pure (1.7.5)
|
21
|
+
method_source (0.8)
|
22
|
+
multi_json (1.3.6)
|
23
|
+
pry (0.9.10)
|
24
24
|
coderay (~> 1.0.5)
|
25
|
-
method_source (~> 0.
|
26
|
-
slop (
|
27
|
-
pry (0.
|
28
|
-
|
29
|
-
method_source (~> 0.7.1)
|
30
|
-
slop (>= 2.4.4, < 3)
|
31
|
-
spoon (~> 0.0)
|
32
|
-
pry-nav (0.2.0)
|
33
|
-
pry (~> 0.9.8.1)
|
25
|
+
method_source (~> 0.8)
|
26
|
+
slop (~> 3.3.1)
|
27
|
+
pry-nav (0.2.2)
|
28
|
+
pry (~> 0.9.10)
|
34
29
|
rake (0.9.2.2)
|
35
|
-
rspec (2.
|
36
|
-
rspec-core (~> 2.
|
37
|
-
rspec-expectations (~> 2.
|
38
|
-
rspec-mocks (~> 2.
|
39
|
-
rspec-core (2.
|
40
|
-
rspec-expectations (2.
|
30
|
+
rspec (2.11.0)
|
31
|
+
rspec-core (~> 2.11.0)
|
32
|
+
rspec-expectations (~> 2.11.0)
|
33
|
+
rspec-mocks (~> 2.11.0)
|
34
|
+
rspec-core (2.11.1)
|
35
|
+
rspec-expectations (2.11.3)
|
41
36
|
diff-lcs (~> 1.1.3)
|
42
|
-
rspec-mocks (2.
|
43
|
-
simplecov (0.6.
|
37
|
+
rspec-mocks (2.11.2)
|
38
|
+
simplecov (0.6.4)
|
44
39
|
multi_json (~> 1.0)
|
45
40
|
simplecov-html (~> 0.5.3)
|
46
41
|
simplecov-html (0.5.3)
|
47
|
-
slop (
|
48
|
-
|
49
|
-
yard (0.7.5)
|
42
|
+
slop (3.3.3)
|
43
|
+
yard (0.8.2.1)
|
50
44
|
|
51
45
|
PLATFORMS
|
52
|
-
java
|
53
46
|
ruby
|
54
47
|
|
55
48
|
DEPENDENCIES
|
data/bin/rpc_server
CHANGED
@@ -12,6 +12,8 @@ require 'protobuf/rpc/servers/zmq_runner'
|
|
12
12
|
server = OpenStruct.new({
|
13
13
|
:app => nil,
|
14
14
|
:env => ENV['RPC_SERVER_ENV'] || 'development',
|
15
|
+
:gc_pause_during_request => false,
|
16
|
+
:gc_pause_during_serialization => false,
|
15
17
|
:host => '127.0.0.1',
|
16
18
|
:port => 9595,
|
17
19
|
:backlog => 100,
|
@@ -76,6 +78,14 @@ parser = OptionParser.new do |opts|
|
|
76
78
|
|
77
79
|
server.runner = ::Protobuf::Rpc::ZmqRunner
|
78
80
|
end
|
81
|
+
|
82
|
+
opts.on("--[no-]gc-pause-request", "Enable/Disable GC pause during request.") do |v|
|
83
|
+
server.gc_pause_during_request = v
|
84
|
+
end
|
85
|
+
|
86
|
+
opts.on("--[no-]gc-pause-serialization", "Enable/Disable GC pause during serialization.") do |v|
|
87
|
+
server.gc_pause_during_serialization = v
|
88
|
+
end
|
79
89
|
|
80
90
|
opts.on("-d", "--[no-]debug", "Debug Mode. Override log level to DEBUG.") do |v|
|
81
91
|
server.debug = v
|
@@ -120,6 +130,13 @@ elsif(ENV['PB_SERVER_TYPE'] =~ /socket/i)
|
|
120
130
|
server.runner = ::Protobuf::Rpc::SocketRunner
|
121
131
|
end
|
122
132
|
|
133
|
+
##
|
134
|
+
# Setup GC settings
|
135
|
+
#
|
136
|
+
::Protobuf::Rpc::GC_PAUSE_REQUEST = server.gc_pause_during_request
|
137
|
+
# If we pause during request we don't need to pause in serialization
|
138
|
+
::Protobuf::Rpc::GC_PAUSE_SERIALIZATION = (!server.gc_pause_during_request && server.gc_pause_during_serialization)
|
139
|
+
|
123
140
|
# protobuf.rb picks up PB_CLIENT_TYPE and PB_SERVER_TYPE and does something
|
124
141
|
# useful with them
|
125
142
|
require 'protobuf'
|
@@ -141,11 +158,11 @@ begin
|
|
141
158
|
end
|
142
159
|
|
143
160
|
# Configure the ::Protobuf::Logger
|
144
|
-
::Protobuf::Logger.configure
|
161
|
+
::Protobuf::Logger.configure(:file => server.log, :level => server.debug ? ::Logger::DEBUG : server.level)
|
145
162
|
|
146
163
|
# Output the server opts
|
147
|
-
::Protobuf::Logger.debug 'Debugging options:'
|
148
|
-
::Protobuf::Logger.debug server.inspect
|
164
|
+
::Protobuf::Logger.debug { 'Debugging options:' }
|
165
|
+
::Protobuf::Logger.debug { server.inspect }
|
149
166
|
|
150
167
|
# Set the name of the process
|
151
168
|
$0 = 'rpc_server %s:%d %s' % [server.host, server.port, server.app]
|
@@ -156,8 +173,8 @@ begin
|
|
156
173
|
server.runner.run(server)
|
157
174
|
rescue
|
158
175
|
msg = 'ERROR: RPC Server failed to start. %s' % $!.inspect
|
159
|
-
$stderr.puts
|
160
|
-
::Protobuf::Logger.error msg
|
161
|
-
::Protobuf::Logger.error $!.backtrace.join("\n")
|
176
|
+
$stderr.puts(msg, *($!.backtrace))
|
177
|
+
::Protobuf::Logger.error { msg }
|
178
|
+
::Protobuf::Logger.error { $!.backtrace.join("\n") }
|
162
179
|
exit 1
|
163
180
|
end
|
@@ -120,28 +120,26 @@ module Protobuf
|
|
120
120
|
raise NotImplementedError, "#{self.class.name}\#encode"
|
121
121
|
end
|
122
122
|
|
123
|
-
|
124
|
-
|
125
|
-
if repeated?
|
126
|
-
merge_array(message_instance, value)
|
127
|
-
else
|
128
|
-
merge_value(message_instance, value)
|
129
|
-
end
|
123
|
+
def extension?
|
124
|
+
!!@extension
|
130
125
|
end
|
131
126
|
|
132
127
|
# Is this a repeated field?
|
133
128
|
def repeated?
|
134
|
-
@
|
129
|
+
return @_repeated unless @_repeated.nil?
|
130
|
+
@_repeated = (@rule == :repeated)
|
135
131
|
end
|
136
132
|
|
137
133
|
# Is this a required field?
|
138
134
|
def required?
|
139
|
-
@
|
135
|
+
return @_required unless @_required.nil?
|
136
|
+
@_required = (@rule == :required)
|
140
137
|
end
|
141
138
|
|
142
139
|
# Is this a optional field?
|
143
140
|
def optional?
|
144
|
-
@
|
141
|
+
return @_optional unless @_optional.nil?
|
142
|
+
@_optional = (@rule == :optional)
|
145
143
|
end
|
146
144
|
|
147
145
|
# Is this a packed repeated field?
|
@@ -183,11 +181,12 @@ module Protobuf
|
|
183
181
|
field = self
|
184
182
|
@message_class.class_eval do
|
185
183
|
define_method(field.name) do
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
184
|
+
@values[field.name] || field.default_value
|
185
|
+
# if @values.has_key?(field.name)
|
186
|
+
# @values[field.name]
|
187
|
+
# else
|
188
|
+
# field.default_value
|
189
|
+
# end
|
191
190
|
end
|
192
191
|
end
|
193
192
|
end
|
@@ -214,14 +213,6 @@ module Protobuf
|
|
214
213
|
end
|
215
214
|
end
|
216
215
|
|
217
|
-
def merge_array(message_instance, value)
|
218
|
-
message_instance.__send__(@name).concat(value)
|
219
|
-
end
|
220
|
-
|
221
|
-
def merge_value(message_instance, value)
|
222
|
-
message_instance.__send__("#{@name}=", value)
|
223
|
-
end
|
224
|
-
|
225
216
|
def typed_default_value
|
226
217
|
if @default.nil?
|
227
218
|
self.class.default
|
@@ -365,7 +356,7 @@ module Protobuf
|
|
365
356
|
UINT32_MAX = 2**32 - 1
|
366
357
|
UINT64_MAX = 2**64 - 1
|
367
358
|
|
368
|
-
class <<self
|
359
|
+
class << self
|
369
360
|
def default
|
370
361
|
0
|
371
362
|
end
|
@@ -638,9 +629,6 @@ module Protobuf
|
|
638
629
|
end
|
639
630
|
end
|
640
631
|
|
641
|
-
def merge_value(message_instance, value)
|
642
|
-
message_instance.__send__(@name).merge_from(value)
|
643
|
-
end
|
644
632
|
end
|
645
633
|
|
646
634
|
|
@@ -28,6 +28,14 @@ module Protobuf
|
|
28
28
|
class << self
|
29
29
|
include Protoable
|
30
30
|
|
31
|
+
def all_fields
|
32
|
+
@all_fields ||= begin
|
33
|
+
fields_hash = fields.merge(extension_fields)
|
34
|
+
ordered_keys = fields_hash.keys.sort
|
35
|
+
ordered_keys.map { |key| fields_hash[key] }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
31
39
|
# Reserve field numbers for extensions. Don't use this method directly.
|
32
40
|
def extensions(range)
|
33
41
|
@extension_fields = ExtensionFields.new(range)
|
@@ -48,33 +56,58 @@ module Protobuf
|
|
48
56
|
define_field(:repeated, type, name, tag, options)
|
49
57
|
end
|
50
58
|
|
59
|
+
def descriptor
|
60
|
+
@descriptor ||= Descriptor::Descriptor.new(self)
|
61
|
+
end
|
62
|
+
|
51
63
|
# Define a field. Don't use this method directly.
|
52
64
|
def define_field(rule, type, fname, tag, options)
|
53
65
|
field_hash = options[:extension] ? extension_fields : fields
|
66
|
+
field_name_hash = options[:extension] ? extension_fields_by_name : fields_by_name
|
67
|
+
|
54
68
|
if field_hash.keys.include?(tag)
|
55
69
|
raise TagCollisionError, %!{Field number #{tag} has already been used in "#{self.name}" by field "#{fname}".!
|
56
70
|
end
|
57
|
-
|
71
|
+
|
72
|
+
field_definition = Field.build(self, rule, type, fname, tag, options)
|
73
|
+
field_name_hash[fname.to_sym] = field_definition
|
74
|
+
field_hash[tag] = field_definition
|
58
75
|
end
|
59
76
|
|
60
77
|
def extension_tag?(tag)
|
61
78
|
extension_fields.include_tag?(tag)
|
62
79
|
end
|
80
|
+
|
81
|
+
# An extension field object.
|
82
|
+
def extension_fields
|
83
|
+
@extension_fields ||= ExtensionFields.new
|
84
|
+
end
|
85
|
+
|
86
|
+
def extension_fields_by_name
|
87
|
+
@extension_fields_by_name ||= {}
|
88
|
+
end
|
63
89
|
|
64
90
|
# A collection of field object.
|
65
91
|
def fields
|
66
92
|
@fields ||= {}
|
67
93
|
end
|
68
94
|
|
69
|
-
|
70
|
-
|
71
|
-
|
95
|
+
def fields_by_name
|
96
|
+
@field_by_name ||= {}
|
97
|
+
end
|
98
|
+
|
99
|
+
def repeated_fields
|
100
|
+
@repeated_fields ||= []
|
101
|
+
end
|
102
|
+
|
103
|
+
def repeated_extension_fields
|
104
|
+
@repeated_extension_fields ||= []
|
72
105
|
end
|
73
106
|
|
74
107
|
# Find a field object by +name+.
|
75
108
|
def get_field_by_name(name)
|
76
|
-
name
|
77
|
-
|
109
|
+
# Check if the name has been used before, if not then set it to the sym value
|
110
|
+
fields_by_name[name] ||= fields_by_name[name.to_sym]
|
78
111
|
end
|
79
112
|
|
80
113
|
# Find a field object by +tag+ number.
|
@@ -82,9 +115,13 @@ module Protobuf
|
|
82
115
|
fields[tag]
|
83
116
|
end
|
84
117
|
|
118
|
+
def field_cache
|
119
|
+
@field_cache ||= {}
|
120
|
+
end
|
121
|
+
|
85
122
|
# Find a field object by +tag_or_name+.
|
86
123
|
def get_field(tag_or_name)
|
87
|
-
case tag_or_name
|
124
|
+
field_cache[tag_or_name] ||= case tag_or_name
|
88
125
|
when Integer then get_field_by_tag(tag_or_name)
|
89
126
|
when String, Symbol then get_field_by_name(tag_or_name)
|
90
127
|
else raise TypeError, tag_or_name.class
|
@@ -93,8 +130,8 @@ module Protobuf
|
|
93
130
|
|
94
131
|
#TODO merge to get_field_by_name
|
95
132
|
def get_ext_field_by_name(name)
|
96
|
-
name
|
97
|
-
|
133
|
+
# Check if the name has been used before, if not then set it to the sym value
|
134
|
+
extension_fields_by_name[name] ||= extension_fields_by_name[name.to_sym]
|
98
135
|
end
|
99
136
|
|
100
137
|
#TODO merge to get_field_by_tag
|
@@ -111,36 +148,68 @@ module Protobuf
|
|
111
148
|
end
|
112
149
|
end
|
113
150
|
|
114
|
-
def
|
115
|
-
@
|
151
|
+
def initialize_unready_fields
|
152
|
+
unless @unready_initialized
|
153
|
+
initialize_type_fields
|
154
|
+
initialize_type_extension_fields
|
155
|
+
@unready_initialized = true
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def initialize_type_fields
|
160
|
+
fields.each do |tag, field|
|
161
|
+
unless field.ready?
|
162
|
+
field = field.setup
|
163
|
+
fields[tag] = field
|
164
|
+
fields_by_name[field.name.to_sym] = field
|
165
|
+
fields_by_name[field.name] = field
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def initialize_type_extension_fields
|
171
|
+
extension_fields.each do |tag, field|
|
172
|
+
unless field.ready?
|
173
|
+
field = field.setup
|
174
|
+
extension_fields[tag] = field
|
175
|
+
extension_fields_by_name[field.name.to_sym] = field
|
176
|
+
extension_fields_by_name[field.name] = field
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
def setup_repeated_field_arrays
|
182
|
+
unless @repeated_fields_setup
|
183
|
+
all_fields.each do |field|
|
184
|
+
next unless field.repeated?
|
185
|
+
|
186
|
+
if field.extension?
|
187
|
+
repeated_extension_fields << field
|
188
|
+
else
|
189
|
+
repeated_fields << field
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
@repeated_fields_setup = true
|
194
|
+
end
|
116
195
|
end
|
117
196
|
end
|
118
197
|
|
119
198
|
def initialize(values={})
|
120
199
|
@values = {}
|
121
200
|
|
122
|
-
self.class.
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
if field.repeated?
|
128
|
-
@values[field.name] = Field::FieldArray.new(field)
|
129
|
-
end
|
201
|
+
self.class.initialize_unready_fields
|
202
|
+
self.class.setup_repeated_field_arrays
|
203
|
+
|
204
|
+
self.class.repeated_fields.each do |field|
|
205
|
+
@values[field.name] = Field::FieldArray.new(field)
|
130
206
|
end
|
131
207
|
|
132
|
-
|
133
|
-
|
134
|
-
unless field.ready?
|
135
|
-
field = field.setup
|
136
|
-
self.class.class_eval {@extension_fields[tag] = field}
|
137
|
-
end
|
138
|
-
if field.repeated?
|
139
|
-
@values[field.name] = Field::FieldArray.new(field)
|
140
|
-
end
|
208
|
+
self.class.repeated_extension_fields.each do |field|
|
209
|
+
@values[field.name] = Field::FieldArray.new(field)
|
141
210
|
end
|
142
211
|
|
143
|
-
values.each {|tag, val| self[tag] = val}
|
212
|
+
values.each { |tag, val| self[tag] = val}
|
144
213
|
end
|
145
214
|
|
146
215
|
def initialized?
|
@@ -205,7 +274,7 @@ module Protobuf
|
|
205
274
|
def inspect(indent=0)
|
206
275
|
result = []
|
207
276
|
i = ' ' * indent
|
208
|
-
field_value_to_string = lambda {|field, value|
|
277
|
+
field_value_to_string = lambda { |field, value|
|
209
278
|
result << \
|
210
279
|
if field.optional? && ! has_field?(field.name)
|
211
280
|
''
|
@@ -281,22 +350,11 @@ module Protobuf
|
|
281
350
|
Encoder.encode(stream, self)
|
282
351
|
end
|
283
352
|
|
284
|
-
def merge_from(message)
|
285
|
-
# TODO
|
286
|
-
fields.each {|tag, field| merge_field(tag, message.__send__(field.name))}
|
287
|
-
extension_fields.each {|tag, field| merge_field(tag, message.__send__(field.name))}
|
288
|
-
end
|
289
|
-
|
290
353
|
def set_field(tag, bytes)
|
291
354
|
field = (get_field_by_tag(tag) || get_ext_field_by_tag(tag))
|
292
355
|
field.set(self, bytes) if field
|
293
356
|
end
|
294
357
|
|
295
|
-
def merge_field(tag, value)
|
296
|
-
#get_field_by_tag(tag).merge self, bytes #TODO
|
297
|
-
(get_field_by_tag(tag) || get_ext_field_by_tag(tag)).merge(self, value)
|
298
|
-
end
|
299
|
-
|
300
358
|
def [](tag_or_name)
|
301
359
|
if field = get_field(tag_or_name) || get_ext_field(tag_or_name)
|
302
360
|
__send__(field.name)
|
@@ -314,8 +372,12 @@ module Protobuf
|
|
314
372
|
end
|
315
373
|
|
316
374
|
# Returns a hash; which key is a tag number, and value is a field object.
|
375
|
+
def all_fields
|
376
|
+
@_all_fields ||= self.class.all_fields
|
377
|
+
end
|
378
|
+
|
317
379
|
def fields
|
318
|
-
self.class.fields
|
380
|
+
@_fields ||= self.class.fields
|
319
381
|
end
|
320
382
|
|
321
383
|
# Returns field object or +nil+.
|
@@ -355,7 +417,7 @@ module Protobuf
|
|
355
417
|
# # do something
|
356
418
|
# end
|
357
419
|
def each_field
|
358
|
-
|
420
|
+
all_fields.each do |field|
|
359
421
|
value = __send__(field.name)
|
360
422
|
yield(field, value)
|
361
423
|
end
|
@@ -363,7 +425,7 @@ module Protobuf
|
|
363
425
|
|
364
426
|
def to_hash
|
365
427
|
result = {}
|
366
|
-
build_value = lambda {|field, value|
|
428
|
+
build_value = lambda { |field, value|
|
367
429
|
if !field.optional? || (field.optional? && has_field?(field.name))
|
368
430
|
case field
|
369
431
|
when Field::MessageField then
|
data/lib/protobuf/rpc/server.rb
CHANGED
@@ -8,6 +8,16 @@ module Protobuf
|
|
8
8
|
module Rpc
|
9
9
|
module Server
|
10
10
|
|
11
|
+
def _gc_pause_request
|
12
|
+
return @_gc_pause_request unless @_gc_pause_request.nil?
|
13
|
+
@_gc_pause_request ||= (defined?(::Protobuf::Rpc::GC_PAUSE_REQUEST) && ::Protobuf::Rpc::GC_PAUSE_REQUEST)
|
14
|
+
end
|
15
|
+
|
16
|
+
def _gc_pause_serialization
|
17
|
+
return @_gc_pause_serialization unless @_gc_pause_serialization.nil?
|
18
|
+
@_gc_pause_serialization ||= (defined?(::Protobuf::Rpc::GC_PAUSE_SERIALIZATION) && ::Protobuf::Rpc::GC_PAUSE_SERIALIZATION)
|
19
|
+
end
|
20
|
+
|
11
21
|
# Invoke the service method dictated by the proto wrapper request object
|
12
22
|
def handle_client
|
13
23
|
# Parse the protobuf request from the socket
|
@@ -20,6 +30,7 @@ module Protobuf
|
|
20
30
|
|
21
31
|
# Call the service method
|
22
32
|
log_debug { "[#{log_signature}] Dispatching client request to service" }
|
33
|
+
GC.disable if _gc_pause_request
|
23
34
|
invoke_rpc_method
|
24
35
|
rescue => error
|
25
36
|
# Ensure we're handling any errors that try to slip out the back door
|
@@ -132,13 +143,18 @@ module Protobuf
|
|
132
143
|
@stats.end
|
133
144
|
@stats.log_stats
|
134
145
|
@did_respond = true
|
146
|
+
ensure
|
147
|
+
GC.enable if _gc_pause_request
|
135
148
|
end
|
136
149
|
|
137
150
|
def serialize_response(response)
|
151
|
+
GC.disable if _gc_pause_serialization
|
138
152
|
log_debug { "[#{log_signature}] serializing response: %s" % response.inspect }
|
139
153
|
@response.response_proto = response.serialize_to_string
|
140
154
|
rescue
|
141
155
|
raise BadResponseProto, $!.message
|
156
|
+
ensure
|
157
|
+
GC.enable if _gc_pause_serialization
|
142
158
|
end
|
143
159
|
end
|
144
160
|
end
|
@@ -3,12 +3,12 @@ module Protobuf
|
|
3
3
|
class SocketRunner
|
4
4
|
|
5
5
|
def self.stop
|
6
|
-
Protobuf::Rpc::Socket::Server.stop
|
7
|
-
Protobuf::Logger.info 'Shutdown complete'
|
6
|
+
::Protobuf::Rpc::Socket::Server.stop
|
7
|
+
::Protobuf::Logger.info { 'Shutdown complete' }
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.run(server)
|
11
|
-
Protobuf::Logger.info "Socket::Server Running"
|
11
|
+
::Protobuf::Logger.info { "Socket::Server Running" }
|
12
12
|
server_config = case
|
13
13
|
when server.is_a?(OpenStruct) then
|
14
14
|
server.marshal_dump
|
@@ -20,9 +20,9 @@ module Protobuf
|
|
20
20
|
raise "Cannot parser Socket Server - server options"
|
21
21
|
end
|
22
22
|
|
23
|
-
Protobuf::Rpc::Socket::Server.run(server_config)
|
23
|
+
::Protobuf::Rpc::Socket::Server.run(server_config)
|
24
24
|
end
|
25
|
-
end
|
26
25
|
|
26
|
+
end
|
27
27
|
end
|
28
28
|
end
|
@@ -12,7 +12,6 @@ module Protobuf
|
|
12
12
|
# Constructor
|
13
13
|
#
|
14
14
|
def initialize(opts={})
|
15
|
-
|
16
15
|
@options = opts
|
17
16
|
host = @options.fetch(:host, "127.0.0.1")
|
18
17
|
port = @options.fetch(:port, 9400)
|
@@ -60,7 +59,7 @@ module Protobuf
|
|
60
59
|
end
|
61
60
|
|
62
61
|
def send_data
|
63
|
-
response_data = @response.is_a?(Protobuf::Message) ? @response.serialize_to_string : @response.to_s
|
62
|
+
response_data = @response.is_a?(::Protobuf::Message) ? @response.serialize_to_string : @response.to_s
|
64
63
|
@stats.response_size = response_data.size
|
65
64
|
zmq_error_check(@socket.send_string(response_data))
|
66
65
|
@did_respond = true
|
data/lib/protobuf/version.rb
CHANGED
@@ -76,7 +76,7 @@ describe Protobuf::Logger do
|
|
76
76
|
subject.fatal 'No errors here'
|
77
77
|
subject.add 'No errors here'
|
78
78
|
subject.log 'No errors here'
|
79
|
-
}.
|
79
|
+
}.to_not raise_error
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'logs correctly when instance is valid' do
|
@@ -118,4 +118,4 @@ describe Protobuf::Logger do
|
|
118
118
|
|
119
119
|
end
|
120
120
|
|
121
|
-
end
|
121
|
+
end
|
@@ -161,7 +161,7 @@ describe Protobuf::Rpc::Client do
|
|
161
161
|
it 'should respond to defined service methods' do
|
162
162
|
client = Spec::Proto::TestService.client
|
163
163
|
client.should_receive(:send_request).and_return(nil)
|
164
|
-
expect { client.find(nil) }.
|
164
|
+
expect { client.find(nil) }.to_not raise_error
|
165
165
|
end
|
166
166
|
|
167
167
|
it 'raises a NameError when accessing a var that does not exist' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protobuf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-09-18 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: eventmachine
|
17
|
-
requirement: &
|
17
|
+
requirement: &2161594760 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2161594760
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: eventually
|
28
|
-
requirement: &
|
28
|
+
requirement: &2161594340 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2161594340
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: json_pure
|
39
|
-
requirement: &
|
39
|
+
requirement: &2161593920 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2161593920
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: ffi-rzmq
|
50
|
-
requirement: &
|
50
|
+
requirement: &2161593500 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: '0'
|
56
56
|
type: :runtime
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *2161593500
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: rake
|
61
|
-
requirement: &
|
61
|
+
requirement: &2161593080 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: '0'
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *2161593080
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: pry
|
72
|
-
requirement: &
|
72
|
+
requirement: &2161592660 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ! '>='
|
@@ -77,10 +77,10 @@ dependencies:
|
|
77
77
|
version: '0'
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *2161592660
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: pry-nav
|
83
|
-
requirement: &
|
83
|
+
requirement: &2161592240 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ! '>='
|
@@ -88,10 +88,10 @@ dependencies:
|
|
88
88
|
version: '0'
|
89
89
|
type: :development
|
90
90
|
prerelease: false
|
91
|
-
version_requirements: *
|
91
|
+
version_requirements: *2161592240
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: rspec
|
94
|
-
requirement: &
|
94
|
+
requirement: &2161591820 !ruby/object:Gem::Requirement
|
95
95
|
none: false
|
96
96
|
requirements:
|
97
97
|
- - ! '>='
|
@@ -99,10 +99,10 @@ dependencies:
|
|
99
99
|
version: '0'
|
100
100
|
type: :development
|
101
101
|
prerelease: false
|
102
|
-
version_requirements: *
|
102
|
+
version_requirements: *2161591820
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: yard
|
105
|
-
requirement: &
|
105
|
+
requirement: &2161591400 !ruby/object:Gem::Requirement
|
106
106
|
none: false
|
107
107
|
requirements:
|
108
108
|
- - ! '>='
|
@@ -110,10 +110,10 @@ dependencies:
|
|
110
110
|
version: '0'
|
111
111
|
type: :development
|
112
112
|
prerelease: false
|
113
|
-
version_requirements: *
|
113
|
+
version_requirements: *2161591400
|
114
114
|
- !ruby/object:Gem::Dependency
|
115
115
|
name: simplecov
|
116
|
-
requirement: &
|
116
|
+
requirement: &2161590980 !ruby/object:Gem::Requirement
|
117
117
|
none: false
|
118
118
|
requirements:
|
119
119
|
- - ! '>='
|
@@ -121,7 +121,7 @@ dependencies:
|
|
121
121
|
version: '0'
|
122
122
|
type: :development
|
123
123
|
prerelease: false
|
124
|
-
version_requirements: *
|
124
|
+
version_requirements: *2161590980
|
125
125
|
description: ! 'Ruby implementation for Protocol Buffers. Works with other protobuf
|
126
126
|
rpc implementations (e.g. Java, Python, C++).
|
127
127
|
|