protobuf 3.10.0 → 3.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 278b7883f457cfa823f9c9d0d4330b1978086a0ad4d1b3e08cb479fbde256f15
4
- data.tar.gz: d1e6232e9a9b1074d66f35c4790d5590f48775f5dec73fb2f15777f11b505ddf
3
+ metadata.gz: 8631e0e157cd16a50b428ca4888a48d8b294002e1844beca975db88c696038ed
4
+ data.tar.gz: 9111c88f5b491c625155ce1ee683f0462778a3b7ae9e49671333275e9829bca0
5
5
  SHA512:
6
- metadata.gz: ce7aac680a1638e2dd848869ee2d002bc1c0554f9d37831843cbdfd18fff370377958e3f5ae8d72e610256e4e7bc83ff23bf3062fef05bb7985e9670d6855f01
7
- data.tar.gz: caaae07d19d4299b3d216c803151ce2965604723ba6e5fa6cbcfb246c8ae1d2eefc0413be02d5d196b7189cf134cbe070d1be1ccb7d29bea1072074c22347b3a
6
+ metadata.gz: bb3d3ee59579cb21771885ebd0ee7bda1e0aa09736cfc15b3053ca9b6206769b5e4eaa2ea8b8ad4d3fb77a85b0dfc985cd69012bda90c0ee23d8e673aed6e373
7
+ data.tar.gz: feb9889203fa3fc6d33c6efeb74fe8a22ccca41af5bb1f3e15f517ce0a1b8fff07b5a1145117f056dbd5a314498ea70851240dd77969fd7b82742b700e5d1bea
@@ -63,8 +63,9 @@ module Protobuf
63
63
  # @param [String] message The error message
64
64
  def failure(code, message)
65
65
  @error = ClientError.new
66
- @error.code = ::Protobuf::Socketrpc::ErrorReason.fetch(code)
66
+ @stats.status = @error.code = ::Protobuf::Socketrpc::ErrorReason.fetch(code)
67
67
  @error.message = message
68
+
68
69
  logger.debug { sign_message("Server failed request (invoking on_failure): #{@error.inspect}") }
69
70
 
70
71
  @failure_cb.call(@error) unless @failure_cb.nil?
@@ -1,16 +1,30 @@
1
1
  require 'date'
2
2
  require 'time'
3
3
  require 'protobuf/logging'
4
+ require 'protobuf/rpc/rpc.pb'
4
5
 
5
6
  module Protobuf
6
7
  module Rpc
7
8
  class Stat
8
9
  attr_accessor :mode, :start_time, :end_time, :request_size, :dispatcher
9
- attr_accessor :response_size, :client, :service, :method_name
10
+ attr_accessor :response_size, :client, :service, :method_name, :status
10
11
  attr_reader :server
11
12
 
12
13
  MODES = [:SERVER, :CLIENT].freeze
13
14
 
15
+ ERROR_TRANSLATIONS = {
16
+ ::Protobuf::Socketrpc::ErrorReason::BAD_REQUEST_DATA => "BAD_REQUEST_DATA",
17
+ ::Protobuf::Socketrpc::ErrorReason::BAD_REQUEST_PROTO => "BAD_REQUEST_PROTO",
18
+ ::Protobuf::Socketrpc::ErrorReason::SERVICE_NOT_FOUND => "SERVICE_NOT_FOUND",
19
+ ::Protobuf::Socketrpc::ErrorReason::METHOD_NOT_FOUND => "METHOD_NOT_FOUND",
20
+ ::Protobuf::Socketrpc::ErrorReason::RPC_ERROR => "RPC_ERROR",
21
+ ::Protobuf::Socketrpc::ErrorReason::RPC_FAILED => "RPC_FAILED",
22
+ ::Protobuf::Socketrpc::ErrorReason::INVALID_REQUEST_PROTO => "INVALID_REQUEST_PROTO",
23
+ ::Protobuf::Socketrpc::ErrorReason::BAD_RESPONSE_PROTO => "BAD_RESPONSE_PROTO",
24
+ ::Protobuf::Socketrpc::ErrorReason::UNKNOWN_HOST => "UNKNOWN_HOST",
25
+ ::Protobuf::Socketrpc::ErrorReason::IO_ERROR => "IO_ERROR",
26
+ }.freeze
27
+
14
28
  def initialize(mode = :SERVER)
15
29
  @mode = mode
16
30
  @request_size = 0
@@ -78,6 +92,12 @@ module Protobuf
78
92
  @mode == :CLIENT
79
93
  end
80
94
 
95
+ def status_string
96
+ return "OK" if status.nil?
97
+
98
+ ERROR_TRANSLATIONS.fetch(status, "UNKNOWN_ERROR")
99
+ end
100
+
81
101
  def to_s
82
102
  [
83
103
  server? ? "[SRV]" : "[CLT]",
@@ -86,6 +106,7 @@ module Protobuf
86
106
  rpc,
87
107
  sizes,
88
108
  elapsed_time,
109
+ status_string,
89
110
  @end_time.try(:iso8601),
90
111
  ].compact.join(' - ')
91
112
  end
@@ -93,7 +114,6 @@ module Protobuf
93
114
  def trace_id
94
115
  ::Thread.current.object_id.to_s(16)
95
116
  end
96
-
97
117
  end
98
118
  end
99
119
  end
@@ -1,3 +1,3 @@
1
1
  module Protobuf
2
- VERSION = '3.10.0' # rubocop:disable Style/MutableConstant
2
+ VERSION = '3.10.1' # rubocop:disable Style/MutableConstant
3
3
  end
@@ -187,14 +187,14 @@ RSpec.describe Protobuf::Rpc::Connectors::Base do
187
187
  shared_examples "a ConnectorDisposition" do |meth, cb, *args|
188
188
 
189
189
  it "calls #complete before exit" do
190
- subject.stats = double("Object", :stop => true)
190
+ subject.stats = ::Protobuf::Rpc::Stat.new(:stop => true)
191
191
 
192
192
  expect(subject).to receive(:complete)
193
193
  subject.method(meth).call(*args)
194
194
  end
195
195
 
196
196
  it "calls the #{cb} callback when provided" do
197
- stats = double("Object")
197
+ stats = ::Protobuf::Rpc::Stat.new
198
198
  allow(stats).to receive(:stop).and_return(true)
199
199
  subject.stats = stats
200
200
  some_cb = double("Object")
@@ -205,7 +205,7 @@ RSpec.describe Protobuf::Rpc::Connectors::Base do
205
205
  end
206
206
 
207
207
  it "calls the complete callback when provided" do
208
- stats = double("Object")
208
+ stats = ::Protobuf::Rpc::Stat.new
209
209
  allow(stats).to receive(:stop).and_return(true)
210
210
  subject.stats = stats
211
211
  comp_cb = double("Object")
@@ -217,8 +217,8 @@ RSpec.describe Protobuf::Rpc::Connectors::Base do
217
217
 
218
218
  end
219
219
 
220
- it_behaves_like("a ConnectorDisposition", :failure, "failure_cb", "code", "message")
221
- it_behaves_like("a ConnectorDisposition", :failure, "complete_cb", "code", "message")
220
+ it_behaves_like("a ConnectorDisposition", :failure, "failure_cb", :RPC_ERROR, "message")
221
+ it_behaves_like("a ConnectorDisposition", :failure, "complete_cb", :RPC_ERROR, "message")
222
222
  it_behaves_like("a ConnectorDisposition", :succeed, "complete_cb", "response")
223
223
  it_behaves_like("a ConnectorDisposition", :succeed, "success_cb", "response")
224
224
  it_behaves_like("a ConnectorDisposition", :complete, "complete_cb")
@@ -33,7 +33,7 @@ RSpec.describe ::Protobuf::Rpc::Stat do
33
33
 
34
34
  ::Timecop.freeze(1.62.seconds.from_now) do
35
35
  stats.stop
36
- expect(stats.to_s).to eq "[SRV] - myserver1 - #{stats.trace_id} - BarService#find_bars - 43B/1302B - 1.62s - #{::Time.now.iso8601}"
36
+ expect(stats.to_s).to eq "[SRV] - myserver1 - #{stats.trace_id} - BarService#find_bars - 43B/1302B - 1.62s - OK - #{::Time.now.iso8601}"
37
37
  end
38
38
  end
39
39
  end
@@ -44,7 +44,7 @@ RSpec.describe ::Protobuf::Rpc::Stat do
44
44
  stats.client = 'myserver1'
45
45
  stats.dispatcher = double('dispatcher', :service => BarService.new(:find_bars))
46
46
  stats.request_size = 43
47
- expect(stats.to_s).to eq "[SRV] - myserver1 - #{stats.trace_id} - BarService#find_bars - 43B/-"
47
+ expect(stats.to_s).to eq "[SRV] - myserver1 - #{stats.trace_id} - BarService#find_bars - 43B/- - OK"
48
48
  end
49
49
  end
50
50
  end
@@ -61,12 +61,31 @@ RSpec.describe ::Protobuf::Rpc::Stat do
61
61
 
62
62
  ::Timecop.freeze(0.832.seconds.from_now) do
63
63
  stats.stop
64
- expect(stats.to_s).to eq "[CLT] - myserver1.myhost.com:30000 - #{stats.trace_id} - Foo::BarService#find_bars - 37B/12345B - 0.832s - #{::Time.now.iso8601}"
64
+ expect(stats.to_s).to eq "[CLT] - myserver1.myhost.com:30000 - #{stats.trace_id} - Foo::BarService#find_bars - 37B/12345B - 0.832s - OK - #{::Time.now.iso8601}"
65
65
  end
66
66
 
67
67
  end
68
68
  end
69
69
 
70
+ describe 'error log' do
71
+ it 'resolves error to a string' do
72
+ ::Timecop.freeze(10.minutes.ago) do
73
+ stats = ::Protobuf::Rpc::Stat.new(:CLIENT)
74
+ stats.server = ['30000', 'myserver1.myhost.com']
75
+ stats.service = 'Foo::BarService'
76
+ stats.status = ::Protobuf::Socketrpc::ErrorReason::RPC_ERROR
77
+ stats.method_name = 'find_bars'
78
+ stats.request_size = 37
79
+ stats.response_size = 12345
80
+
81
+ ::Timecop.freeze(0.832.seconds.from_now) do
82
+ stats.stop
83
+ expect(stats.to_s).to eq "[CLT] - myserver1.myhost.com:30000 - #{stats.trace_id} - Foo::BarService#find_bars - 37B/12345B - 0.832s - RPC_ERROR - #{::Time.now.iso8601}"
84
+ end
85
+ end
86
+ end
87
+ end
88
+
70
89
  context 'when request is still running' do
71
90
  it 'omits response size, duration, and timestamp' do
72
91
  stats = ::Protobuf::Rpc::Stat.new(:CLIENT)
@@ -74,7 +93,7 @@ RSpec.describe ::Protobuf::Rpc::Stat do
74
93
  stats.service = 'Foo::BarService'
75
94
  stats.method_name = 'find_bars'
76
95
  stats.request_size = 37
77
- expect(stats.to_s).to eq "[CLT] - myserver1.myhost.com:30000 - #{stats.trace_id} - Foo::BarService#find_bars - 37B/-"
96
+ expect(stats.to_s).to eq "[CLT] - myserver1.myhost.com:30000 - #{stats.trace_id} - Foo::BarService#find_bars - 37B/- - OK"
78
97
  end
79
98
  end
80
99
  end
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: 3.10.0
4
+ version: 3.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - BJ Neilsen
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2019-03-18 00:00:00.000000000 Z
14
+ date: 2019-08-28 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport