protobuf 3.10.5 → 3.10.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +0 -2
- data/lib/protobuf/rpc/error.rb +4 -4
- data/lib/protobuf/rpc/middleware/exception_handler.rb +12 -1
- data/lib/protobuf/version.rb +1 -1
- data/spec/lib/protobuf/rpc/middleware/exception_handler_spec.rb +3 -3
- data/spec/lib/protobuf/rpc/stat_spec.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ea13b6353fc56a116dc91e87662ffaaac8c4b8cb27dd85be480797e7ef922d2
|
4
|
+
data.tar.gz: 6f5804860b80527356f1a6cec79def05499abd4a5536038c453e7e65cd05c237
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a49491b32df80049107f59673008d6f8ac64977abcae332ad407c120f9f9628f4c3b47dbd5f809b8843ce477e02286da3fc1242131a8919ddac7170e2002bbf4
|
7
|
+
data.tar.gz: b5352584a6c79b77ce1360fb0ce6a03c00a165cdfb8f92b96aaf61d37a3acf7a89f7bd4bd2fc8a3f1c879434b941db3e0689040edf5988cee2c05cb5bfd0a3a5
|
data/.circleci/config.yml
CHANGED
data/lib/protobuf/rpc/error.rb
CHANGED
@@ -13,12 +13,12 @@ module Protobuf
|
|
13
13
|
super message
|
14
14
|
end
|
15
15
|
|
16
|
-
def encode
|
17
|
-
to_response.encode
|
16
|
+
def encode(args = {})
|
17
|
+
to_response(args).encode
|
18
18
|
end
|
19
19
|
|
20
|
-
def to_response
|
21
|
-
::Protobuf::Socketrpc::Response.new(:error => message, :error_reason => error_type)
|
20
|
+
def to_response(args = {})
|
21
|
+
::Protobuf::Socketrpc::Response.new({ :error => message, :error_reason => error_type }.merge(args))
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -22,7 +22,7 @@ module Protobuf
|
|
22
22
|
# Rescue exceptions, re-wrap them as generic Protobuf errors,
|
23
23
|
# and encode them
|
24
24
|
env.response = wrap_exception(exception)
|
25
|
-
env.encoded_response = env.response
|
25
|
+
env.encoded_response = wrap_and_encode_with_server(env.response, env)
|
26
26
|
env
|
27
27
|
end
|
28
28
|
|
@@ -34,6 +34,17 @@ module Protobuf
|
|
34
34
|
exception = RpcFailed.new(exception.message) unless exception.is_a?(PbError)
|
35
35
|
exception
|
36
36
|
end
|
37
|
+
|
38
|
+
# If the response is a PbError, it won't have the server merged into the response proto.
|
39
|
+
# We should add it here since exception handler is always at the bottom of the middleware
|
40
|
+
# stack. Without this, the server hostname in the client rpc log will not be set.
|
41
|
+
def wrap_and_encode_with_server(response, env)
|
42
|
+
if response.is_a?(PbError)
|
43
|
+
response.encode(:server => env.server)
|
44
|
+
else
|
45
|
+
response.encode
|
46
|
+
end
|
47
|
+
end
|
37
48
|
end
|
38
49
|
end
|
39
50
|
end
|
data/lib/protobuf/version.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe Protobuf::Rpc::Middleware::ExceptionHandler do
|
4
4
|
let(:app) { proc { |env| env } }
|
5
|
-
let(:env) { Protobuf::Rpc::Env.new }
|
5
|
+
let(:env) { Protobuf::Rpc::Env.new("server" => "cooldude") }
|
6
6
|
|
7
7
|
subject { described_class.new(app) }
|
8
8
|
|
@@ -17,7 +17,7 @@ RSpec.describe Protobuf::Rpc::Middleware::ExceptionHandler do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
context "when exceptions occur" do
|
20
|
-
let(:encoded_error) { error.encode }
|
20
|
+
let(:encoded_error) { error.encode(:server => "cooldude") }
|
21
21
|
let(:error) { Protobuf::Rpc::MethodNotFound.new('Boom!') }
|
22
22
|
|
23
23
|
before { allow(app).to receive(:call).and_raise(error, 'Boom!') }
|
@@ -42,7 +42,7 @@ RSpec.describe Protobuf::Rpc::Middleware::ExceptionHandler do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
context "when exception is not a Protobuf error" do
|
45
|
-
let(:encoded_error) { error.encode }
|
45
|
+
let(:encoded_error) { error.encode(:server => "cooldude") }
|
46
46
|
let(:error) { Protobuf::Rpc::RpcFailed.new('Boom!') }
|
47
47
|
|
48
48
|
before { allow(app).to receive(:call).and_raise(RuntimeError, 'Boom!') }
|
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.
|
4
|
+
version: 3.10.6
|
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:
|
14
|
+
date: 2022-04-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|
@@ -486,7 +486,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
486
486
|
- !ruby/object:Gem::Version
|
487
487
|
version: '0'
|
488
488
|
requirements: []
|
489
|
-
rubygems_version: 3.2.
|
489
|
+
rubygems_version: 3.2.28
|
490
490
|
signing_key:
|
491
491
|
specification_version: 4
|
492
492
|
summary: Google Protocol Buffers serialization and RPC implementation for Ruby.
|