protobuf 1.1.3 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/.gitignore +3 -0
  2. data/Gemfile.lock +44 -25
  3. data/README.md +2 -2
  4. data/Rakefile +15 -0
  5. data/bin/rpc_server +52 -11
  6. data/lib/protobuf.rb +22 -10
  7. data/lib/protobuf/common/logger.rb +26 -25
  8. data/lib/protobuf/descriptor/file_descriptor.rb +1 -1
  9. data/lib/protobuf/message/field.rb +2 -2
  10. data/lib/protobuf/rpc/buffer.rb +30 -25
  11. data/lib/protobuf/rpc/client.rb +8 -8
  12. data/lib/protobuf/rpc/connector.rb +2 -0
  13. data/lib/protobuf/rpc/connectors/base.rb +0 -1
  14. data/lib/protobuf/rpc/connectors/common.rb +48 -48
  15. data/lib/protobuf/rpc/connectors/em_client.rb +53 -27
  16. data/lib/protobuf/rpc/connectors/eventmachine.rb +14 -17
  17. data/lib/protobuf/rpc/connectors/socket.rb +23 -16
  18. data/lib/protobuf/rpc/connectors/zmq.rb +73 -0
  19. data/lib/protobuf/rpc/error.rb +1 -2
  20. data/lib/protobuf/rpc/error/client_error.rb +4 -4
  21. data/lib/protobuf/rpc/server.rb +31 -43
  22. data/lib/protobuf/rpc/servers/evented/server.rb +43 -0
  23. data/lib/protobuf/rpc/servers/evented_runner.rb +1 -1
  24. data/lib/protobuf/rpc/servers/socket/server.rb +108 -0
  25. data/lib/protobuf/rpc/servers/socket/worker.rb +59 -0
  26. data/lib/protobuf/rpc/servers/socket_runner.rb +3 -3
  27. data/lib/protobuf/rpc/servers/zmq/broker.rb +85 -0
  28. data/lib/protobuf/rpc/servers/zmq/server.rb +50 -0
  29. data/lib/protobuf/rpc/servers/zmq/util.rb +27 -0
  30. data/lib/protobuf/rpc/servers/zmq/worker.rb +72 -0
  31. data/lib/protobuf/rpc/servers/zmq_runner.rb +26 -0
  32. data/lib/protobuf/rpc/service.rb +5 -5
  33. data/lib/protobuf/version.rb +1 -1
  34. data/protobuf.gemspec +12 -10
  35. data/spec/benchmark/tasks.rb +37 -5
  36. data/spec/functional/evented_server_spec.rb +64 -0
  37. data/spec/functional/socket_server_spec.rb +63 -0
  38. data/spec/functional/zmq_server_spec.rb +63 -0
  39. data/spec/helper/server.rb +32 -12
  40. data/spec/lib/protobuf/message/encoder_spec.rb +19 -0
  41. data/spec/proto/test.pb.rb +3 -3
  42. data/spec/proto/test.proto +3 -3
  43. data/spec/proto/test_service.rb +1 -0
  44. data/spec/spec_helper.rb +6 -0
  45. data/spec/unit/message_spec.rb +1 -1
  46. data/spec/unit/rpc/client_spec.rb +11 -3
  47. data/spec/unit/rpc/connectors/common_spec.rb +0 -1
  48. data/spec/unit/rpc/connectors/eventmachine_client_spec.rb +32 -0
  49. data/spec/unit/rpc/connectors/socket_spec.rb +2 -4
  50. data/spec/unit/rpc/connectors/zmq_spec.rb +27 -0
  51. data/spec/unit/rpc/servers/evented_server_spec.rb +3 -3
  52. data/spec/unit/rpc/servers/socket_server_spec.rb +14 -13
  53. data/spec/unit/rpc/servers/zmq/broker_spec.rb +27 -0
  54. data/spec/unit/rpc/servers/zmq/server_spec.rb +37 -0
  55. data/spec/unit/rpc/servers/zmq/util_spec.rb +41 -0
  56. data/spec/unit/rpc/servers/zmq/worker_spec.rb +36 -0
  57. data/spec/unit/rpc/service_spec.rb +22 -18
  58. metadata +87 -40
  59. data/lib/protobuf/rpc/servers/evented_server.rb +0 -28
  60. data/lib/protobuf/rpc/servers/socket_server.rb +0 -146
@@ -29,7 +29,7 @@ module Protobuf
29
29
  def initialize(opts={})
30
30
  raise "Invalid client configuration. Service must be defined." if opts[:service].nil?
31
31
  @connector = Connector.connector_for_client.new(opts)
32
- log_debug "[#{log_signature}] Initialized with options: %s" % opts.inspect
32
+ log_debug { "[#{log_signature}] Initialized with options: %s" % opts.inspect }
33
33
  end
34
34
 
35
35
  def log_signature
@@ -109,25 +109,25 @@ module Protobuf
109
109
  def method_missing(method, *params)
110
110
  service = options[:service]
111
111
  unless service.rpcs[service].keys.include?(method)
112
- log_error "[#{log_signature}] %s#%s not rpc method, passing to super" % [service.name, method.to_s]
112
+ log_error { "[#{log_signature}] %s#%s not rpc method, passing to super" % [service.name, method.to_s] }
113
113
  super(method, *params)
114
114
  else
115
- log_debug "[#{log_signature}] %s#%s" % [service.name, method.to_s]
115
+ log_debug { "[#{log_signature}] %s#%s" % [service.name, method.to_s] }
116
116
  rpc = service.rpcs[service][method.to_sym]
117
117
  options[:request_type] = rpc.request_type
118
- log_debug "[#{log_signature}] Request Type: %s" % options[:request_type].name
118
+ log_debug { "[#{log_signature}] Request Type: %s" % options[:request_type].name }
119
119
  options[:response_type] = rpc.response_type
120
- log_debug "[#{log_signature}] Response Type: %s" % options[:response_type].name
120
+ log_debug { "[#{log_signature}] Response Type: %s" % options[:response_type].name }
121
121
  options[:method] = method.to_s
122
122
  options[:request] = params[0].is_a?(Hash) ? options[:request_type].new(params[0]) : params[0]
123
- log_debug "[#{log_signature}] Request Data: %s" % options[:request].inspect
123
+ log_debug { "[#{log_signature}] Request Data: %s" % options[:request].inspect }
124
124
 
125
125
  # Call client to setup on_success and on_failure event callbacks
126
126
  if block_given?
127
- log_debug "[#{log_signature}] client setup callback given, invoking"
127
+ log_debug { "[#{log_signature}] client setup callback given, invoking" }
128
128
  yield(self)
129
129
  else
130
- log_debug "[#{log_signature}] no block given for callbacks"
130
+ log_debug { "[#{log_signature}] no block given for callbacks" }
131
131
  end
132
132
 
133
133
  send_request
@@ -7,6 +7,8 @@ module Protobuf
7
7
  case Protobuf::ClientType
8
8
  when "Socket" then
9
9
  ::Protobuf::Rpc::Connectors::Socket
10
+ when "Zmq" then
11
+ ::Protobuf::Rpc::Connectors::Zmq
10
12
  else
11
13
  ::Protobuf::Rpc::Connectors::EventMachine
12
14
  end
@@ -37,7 +37,6 @@ module Protobuf
37
37
  def async?
38
38
  !!@options[:async]
39
39
  end
40
-
41
40
  end
42
41
  end
43
42
  end
@@ -1,8 +1,8 @@
1
1
  module Protobuf
2
- module Rpc
2
+ module Rpc
3
3
  module Connectors
4
- module Common
5
-
4
+ module Common
5
+
6
6
  attr_reader :error
7
7
 
8
8
  def any_callbacks?
@@ -14,30 +14,34 @@ module Protobuf
14
14
  def complete
15
15
  @stats.end
16
16
  @stats.log_stats
17
- log_debug "[#{log_signature}] Response proceessing complete"
17
+ log_debug { "[#{log_signature}] Response proceessing complete" }
18
18
  @complete_cb.call(self) unless @complete_cb.nil?
19
19
  rescue
20
- log_error "[#{log_signature}] Complete callback error encountered: %s" % $!.message
21
- log_error "[#{log_signature}] %s" % $!.backtrace.join("\n")
20
+ log_error { "[#{log_signature}] Complete callback error encountered: %s" % $!.message }
21
+ log_error { "[#{log_signature}] %s" % $!.backtrace.join("\n") }
22
22
  raise
23
23
  end
24
24
 
25
25
  def data_callback(data)
26
- log_debug "[#{log_signature}] Using data_callback"
26
+ log_debug { "[#{log_signature}] Using data_callback" }
27
27
  @used_data_callback = true
28
28
  @data = data
29
29
  end
30
30
 
31
+ # All failures should be routed through this method
32
+ #
33
+ # @param [Symbol] code The code we're using (see ::Protobuf::Socketrpc::ErrorReason)
34
+ # @param [String] message The error message
31
35
  def fail(code, message)
32
36
  @error = ClientError.new
33
37
  @error.code = code.is_a?(Symbol) ? Protobuf::Socketrpc::ErrorReason.values[code] : code
34
38
  @error.message = message
35
- log_debug "[#{log_signature}] Server failed request (invoking on_failure): %s" % @error.inspect
36
-
39
+ log_debug { "[#{log_signature}] Server failed request (invoking on_failure): %s" % @error.inspect }
40
+
37
41
  @failure_cb.call(@error) unless @failure_cb.nil?
38
42
  rescue
39
- log_error "[#{log_signature}] Failure callback error encountered: %s" % $!.message
40
- log_error "[#{log_signature}] %s" % $!.backtrace.join("\n")
43
+ log_error { "[#{log_signature}] Failure callback error encountered: %s" % $!.message }
44
+ log_error { "[#{log_signature}] %s" % $!.backtrace.join("\n") }
41
45
  raise
42
46
  ensure
43
47
  complete
@@ -47,10 +51,9 @@ module Protobuf
47
51
  @stats = Protobuf::Rpc::Stat.new(:CLIENT, true)
48
52
  @stats.server = [@options[:port], @options[:host]]
49
53
  @stats.service = @options[:service].name
50
- @stats.method = @options[:method]
51
- self
54
+ @stats.method = @options[:method].to_s
52
55
  rescue => ex
53
- fail(:RPC_ERROR, "Invalid stats configuration. #{ex.message}")
56
+ fail(:RPC_ERROR, "Invalid stats configuration. #{ex.message}")
54
57
  end
55
58
 
56
59
  def log_signature
@@ -61,22 +64,21 @@ module Protobuf
61
64
  # Close up the connection as we no longer need it
62
65
  close_connection
63
66
 
64
- log_debug "[#{log_signature}] Parsing response from server (connection closed)"
65
- @stats.response_size = @buffer.size
67
+ log_debug { "[#{log_signature}] Parsing response from server (connection closed)" }
66
68
 
67
69
  # Parse out the raw response
68
70
  response_wrapper = Protobuf::Socketrpc::Response.new
69
- response_wrapper.parse_from_string(@buffer.data)
71
+ response_wrapper.parse_from_string(@response_data)
70
72
 
71
73
  # Determine success or failure based on parsed data
72
74
  if response_wrapper.has_field?(:error_reason)
73
- log_debug "[#{log_signature}] Error response parsed"
75
+ log_debug { "[#{log_signature}] Error response parsed" }
74
76
 
75
77
  # fail the call if we already know the client is failed
76
78
  # (don't try to parse out the response payload)
77
79
  fail(response_wrapper.error_reason, response_wrapper.error)
78
80
  else
79
- log_debug "[#{log_signature}] Successful response parsed"
81
+ log_debug { "[#{log_signature}] Successful response parsed" }
80
82
 
81
83
  # Ensure client_response is an instance
82
84
  response_type = @options[:response_type].new
@@ -92,52 +94,51 @@ module Protobuf
92
94
  end
93
95
  end
94
96
 
95
- # Setup the read buffer for data coming back
96
97
  def post_init
97
- # Setup an object for reponses without callbacks
98
- @data = nil
99
- log_debug "[#{log_signature}] Post init, new read buffer created"
100
- @buffer = Protobuf::Rpc::Buffer.new(:read)
101
- _send_request unless error?
102
- log_debug "[#{log_signature}] Post init, new read buffer created just sent"
98
+ send_data unless error?
103
99
  rescue
104
100
  fail(:RPC_ERROR, 'Connection error: %s' % $!.message)
105
101
  end
106
102
 
107
- # Sends the request to the server, invoked by the connection_completed event
108
- def _send_request
109
- request_wrapper = Protobuf::Socketrpc::Request.new
110
- request_wrapper.service_name = @options[:service].name
111
- request_wrapper.method_name = @options[:method].to_s
103
+ def rpc_request_data
104
+ validate_request_type
112
105
 
113
- if @options[:request].class == @options[:request_type]
114
- request_wrapper.request_proto = @options[:request].serialize_to_string
115
- else
116
- expected = @options[:request_type].name
117
- actual = @options[:request].class.name
118
- fail :INVALID_REQUEST_PROTO, 'Expected request type to be type of %s, got %s instead' % [expected, actual]
119
- end
106
+ return Protobuf::Socketrpc::Request.new(
107
+ :service_name => @options[:service].name,
108
+ :method_name => @options[:method].to_s,
109
+ :request_proto => @options[:request].serialize_to_string
110
+ ).serialize_to_string
111
+ rescue
112
+ fail :INVALID_REQUEST_PROTO, "Could not set request proto: #{$!.message}"
113
+ end
120
114
 
121
- log_debug "[#{log_signature}] Sending Request: %s" % request_wrapper.inspect
122
- request_buffer = Protobuf::Rpc::Buffer.new(:write, request_wrapper)
123
- @stats.request_size = request_buffer.size
124
- send_data(request_buffer.write)
115
+ def setup_connection
116
+ initialize_stats
117
+ @request_data = rpc_request_data
125
118
  end
126
119
 
127
120
  def succeed(response)
128
- log_debug "[#{log_signature}] Server succeeded request (invoking on_success)"
121
+ log_debug { "[#{log_signature}] Server succeeded request (invoking on_success)" }
129
122
  @success_cb.call(response) unless @success_cb.nil?
130
123
  rescue
131
- log_error "[#{log_signature}] Success callback error encountered: %s" % $!.message
132
- log_error "[#{log_signature}] %s" % $!.backtrace.join("\n")
124
+ log_error { "[#{log_signature}] Success callback error encountered: %s" % $!.message }
125
+ log_error { "[#{log_signature}] %s" % $!.backtrace.join("\n") }
133
126
  fail :RPC_ERROR, 'An exception occurred while calling on_success: %s' % $!.message
134
- ensure
127
+ ensure
135
128
  complete
136
129
  end
137
130
 
131
+ def validate_request_type
132
+ unless @options[:request].class == @options[:request_type]
133
+ expected = @options[:request_type].name
134
+ actual = @options[:request].class.name
135
+ fail :INVALID_REQUEST_PROTO, 'Expected request type to be type of %s, got %s instead' % [expected, actual]
136
+ end
137
+ end
138
+
138
139
  def verify_callbacks
139
140
  if !any_callbacks?
140
- log_debug "[#{log_signature}] No callbacks set, using data_callback"
141
+ log_debug { "[#{log_signature}] No callbacks set, using data_callback" }
141
142
  @success_cb = @failure_cb = self.method(:data_callback)
142
143
  end
143
144
  end
@@ -148,7 +149,6 @@ module Protobuf
148
149
  fail(:RPC_ERROR, "Invalid client connection configuration. #{opt} must be a defined option.") if @options[opt].nil?
149
150
  end
150
151
  end
151
-
152
152
  end
153
153
  end
154
154
  end
@@ -2,56 +2,82 @@
2
2
  module Protobuf
3
3
  module Rpc
4
4
  module Connectors
5
-
5
+
6
6
  class EMClient < EM::Connection
7
7
  include Protobuf::Logger::LogMethods
8
8
  include Protobuf::Rpc::Connectors::Common
9
-
9
+
10
10
  attr_reader :options, :request, :response
11
11
  attr_reader :error, :error_reason, :error_message
12
-
13
- class << self
14
-
15
- def connect(options={})
16
- options = DEFAULT_OPTIONS.merge(options)
17
- log_debug "[client-#{self}] Connecting to server: %s" % options.inspect
18
- EM.connect(options[:host], options[:port], self, options)
19
- end
20
12
 
21
- end
22
-
13
+ ##
14
+ # Constructor
15
+ #
23
16
  def initialize(options={}, &failure_cb)
24
17
  @failure_cb = failure_cb
25
18
  @options = DEFAULT_OPTIONS.merge(options)
19
+ @response_buffer = ::Protobuf::Rpc::Buffer.new(:read)
26
20
  verify_options
27
- initialize_stats
28
21
 
29
- log_debug "[#{log_signature}] Client Initialized: %s" % options.inspect
22
+ log_debug { "[#{log_signature}] Client Initialized: %s" % options.inspect }
30
23
  rescue
31
24
  fail(:RPC_ERROR, 'Failed to initialize connection: %s' % $!.message)
32
25
  end
33
26
 
34
- # Success callback registration
35
- def on_success(&success_cb)
36
- @success_cb = success_cb
27
+ ##
28
+ # Class Methods
29
+ #
30
+ def self.connect(options={})
31
+ options = DEFAULT_OPTIONS.merge(options)
32
+ log_debug { "[client-#{self}] Connecting to server: %s" % options.inspect }
33
+ EM.connect(options[:host], options[:port], self, options)
37
34
  end
38
-
39
- # Failure callback registration
40
- def on_failure(&failure_cb)
41
- @failure_cb = failure_cb
35
+
36
+ # turn post_init back into a no-op for event machine
37
+ def post_init
42
38
  end
43
-
39
+
40
+ ##
41
+ # Instance Methods
42
+ #
44
43
  # Completion callback registration
45
44
  def on_complete(&complete_cb)
46
45
  @complete_cb = complete_cb
47
46
  end
48
-
47
+
48
+ # Failure callback registration
49
+ def on_failure(&failure_cb)
50
+ @failure_cb = failure_cb
51
+ end
52
+
53
+ # Success callback registration
54
+ def on_success(&success_cb)
55
+ @success_cb = success_cb
56
+ end
57
+
49
58
  def receive_data(data)
50
- log_debug "[#{log_signature}] receive_data: %s" % data
51
- @buffer << data
52
- parse_response if @buffer.flushed?
59
+ log_debug { "[#{log_signature}] receive_data: %s" % data }
60
+ @response_buffer << data
61
+ @response_data = @response_buffer.data
62
+ parse_response if(!@response_data.nil? && @response_buffer.flushed?)
53
63
  end
54
-
64
+
65
+ def send_data
66
+ request_buffer = ::Protobuf::Rpc::Buffer.new(:write)
67
+ request_buffer.set_data(@request_data)
68
+ log_debug { "[#{log_signature}] sending data: #{request_buffer.inspect}" }
69
+ super(request_buffer.write)
70
+ rescue
71
+ fail(:RPC_ERROR, 'Connection error: %s' % $!.message)
72
+ end
73
+
74
+ # overwriting this method for java because it's broken in eventmachine. See https://github.com/eventmachine/eventmachine/issues/14
75
+ if RUBY_PLATFORM =~ /java/
76
+ def error?
77
+ !!@error
78
+ end
79
+ end
80
+
55
81
  end
56
82
  end
57
83
  end
@@ -11,12 +11,14 @@ module Protobuf
11
11
  f = Fiber.current
12
12
 
13
13
  EM.next_tick do
14
- log_debug "[#{log_signature}] Scheduling EventMachine client request to be created on next tick"
14
+ log_debug { "[#{log_signature}] Scheduling EventMachine client request to be created on next tick" }
15
15
  cnxn = EMClient.connect(options, &ensure_cb)
16
16
  cnxn.on_success(&success_cb) if success_cb
17
17
  cnxn.on_failure(&ensure_cb)
18
18
  cnxn.on_complete { resume_fiber(f) } unless async?
19
- log_debug "[#{log_signature}] Connection scheduled"
19
+ cnxn.setup_connection
20
+ cnxn.send_data
21
+ log_debug { "[#{log_signature}] Connection scheduled" }
20
22
  end
21
23
 
22
24
  async? ? true : set_timeout_and_validate_fiber
@@ -41,10 +43,10 @@ module Protobuf
41
43
 
42
44
  def ensure_em_running(&blk)
43
45
  if EM.reactor_running?
44
- @global_reactor = true
46
+ @using_global_reactor = true
45
47
  yield
46
48
  else
47
- @global_reactor = false
49
+ @using_global_reactor = false
48
50
  EM.fiber_run do
49
51
  blk.call
50
52
  EM.stop
@@ -56,32 +58,27 @@ module Protobuf
56
58
  EM::cancel_timer(@timeout_timer)
57
59
  fib.resume(true)
58
60
  rescue => ex
59
- log_error "[#{log_signature}] An exception occurred while waiting for server response:"
60
- log_error ex.message
61
- log_error ex.backtrace.join("\n")
62
-
63
61
  message = 'Synchronous client failed: %s' % ex.message
64
- err = Protobuf::Rpc::ClientError.new(Protobuf::Socketrpc::ErrorReason::RPC_ERROR, message)
65
- ensure_cb.call(err)
66
- EM.stop if !@global_reactor
62
+ error_stop_reactor(message)
67
63
  end
68
64
 
69
65
  def set_timeout_and_validate_fiber
70
66
  @timeout_timer = EM::add_timer(@options[:timeout]) do
71
67
  message = 'Client timeout of %d seconds expired' % @options[:timeout]
72
- err = Protobuf::Rpc::ClientError.new(Protobuf::Socketrpc::ErrorReason::RPC_ERROR, message)
73
- ensure_cb.call(err)
74
- EM.stop if !@global_reactor
68
+ error_stop_reactor(message)
75
69
  end
76
70
 
77
71
  Fiber.yield
78
72
  rescue FiberError
79
73
  message = "Synchronous calls must be in 'EM.fiber_run' block"
74
+ error_stop_reactor(message)
75
+ end
76
+
77
+ def error_stop_reactor(message)
80
78
  err = Protobuf::Rpc::ClientError.new(Protobuf::Socketrpc::ErrorReason::RPC_ERROR, message)
81
79
  ensure_cb.call(err)
82
- EM.stop if !@global_reactor
83
- end
84
-
80
+ EM.stop unless @using_global_reactor
81
+ end
85
82
  end
86
83
  end
87
84
  end
@@ -6,12 +6,12 @@ module Protobuf
6
6
  class Socket < Base
7
7
  include Protobuf::Rpc::Connectors::Common
8
8
  include Protobuf::Logger::LogMethods
9
-
9
+
10
10
  def send_request
11
11
  check_async
12
- initialize_stats
12
+ setup_connection
13
13
  connect_to_rpc_server
14
- post_init # calls _send_request
14
+ post_init
15
15
  read_response
16
16
  end
17
17
 
@@ -19,26 +19,25 @@ module Protobuf
19
19
 
20
20
  def check_async
21
21
  if async?
22
- log_error "[client-#{self.class}] Cannot run in async mode"
23
- raise "Cannot use Socket client in async mode"
24
- else
25
- log_debug "[client-#{self.class}] Async check passed"
26
- end
22
+ log_error { "[client-#{self.class}] Cannot run in async mode" }
23
+ raise "Cannot use Socket client in async mode"
24
+ end
27
25
  end
28
26
 
29
27
  def close_connection
30
28
  @socket.close
31
- log_debug "[client-#{self.class}] Connector closed"
29
+ log_debug { "[client-#{self.class}] Connector closed" }
32
30
  end
33
31
 
34
32
  def connect_to_rpc_server
35
33
  @socket = TCPSocket.new(options[:host], options[:port])
36
- log_debug "[client-#{self.class}] Connection established #{options[:host]}:#{options[:port]}"
34
+ log_debug { "[client-#{self.class}] Connection established #{options[:host]}:#{options[:port]}" }
37
35
  end
38
36
 
39
37
  # Method to determine error state, must be used with Connector api
40
38
  def error?
41
- log_debug "[client-#{self.class}] Error state : #{@socket.closed?}"
39
+ return true if(@error)
40
+ log_debug { "[client-#{self.class}] Error state : #{@socket.closed?}" }
42
41
  @socket.closed?
43
42
  end
44
43
 
@@ -54,14 +53,22 @@ module Protobuf
54
53
  end
55
54
 
56
55
  def read_response
57
- @buffer << read_data
58
- parse_response if @buffer.flushed?
56
+ log_debug { "[client-#{self.class}] error? is #{error?}" }
57
+ return if(error?)
58
+ response_buffer = ::Protobuf::Rpc::Buffer.new(:read)
59
+ response_buffer << read_data
60
+ @stats.response_size = response_buffer.size
61
+ @response_data = response_buffer.data
62
+ parse_response if response_buffer.flushed?
59
63
  end
60
64
 
61
- def send_data(data)
62
- @socket.write(data)
65
+ def send_data
66
+ return if(error?)
67
+ request_buffer = ::Protobuf::Rpc::Buffer.new(:write)
68
+ request_buffer.set_data(@request_data)
69
+ @socket.write(request_buffer.write)
63
70
  @socket.flush
64
- log_debug "[client-#{self.class}] write closed"
71
+ log_debug { "[client-#{self.class}] write closed" }
65
72
  end
66
73
 
67
74
  end