gruf 2.5.1 → 2.5.2

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: 65e740037fb8efc21bd1560364abb3c9de7ae69d8e443363b8965ab617344e99
4
- data.tar.gz: 2acbd3d7618774210218dac40e033c8d279152793aa9336f7025eb9a2a6c7e30
3
+ metadata.gz: 161c1f1aeb32e9b80985795573d6c8474719043ced9971e7aa8f711daf46c633
4
+ data.tar.gz: 1d320dd2a0973e0889244e4f8fdb949e1b4ef574a1a61af0cbd479881243480d
5
5
  SHA512:
6
- metadata.gz: 1b7130c6564fa22da55c76c28f602f1f56f90033a1df736539bc3c930e9edc3cb2ea5100644fa9ee2d918d6120cc7d6a683f0a81709431a06b7fc870f98eadd6
7
- data.tar.gz: 8247fba2ac2be6f566d9c95bb76c321cc6920e289f082fb0f513c5a3bcfe033b7c5a01c762f1472f20b2c8c401d48187382b89f4cb4faf104c4a8dcf2cedd27d
6
+ metadata.gz: fae96509a53b6e5ed611f1931e3718f2d377b445824de5947d3dd93062a7b07933553c20218297bf66fe83e323192d12fb085acc9adf26963f34377e28f97177
7
+ data.tar.gz: d7ab37d15a0d48db8240a028965310f0988e0a3f57c8ccd7701ba129a0dd08d3378de05d9536b5aeb6eb096515fd4dd9491d93632a322c6c4de43bf2d8eec7fd
@@ -2,6 +2,10 @@ Changelog for the gruf gem. This includes internal history before the gem was ma
2
2
 
3
3
  ### Pending release
4
4
 
5
+ ### 2.5.2
6
+
7
+ - Log ok/validation responses at DEBUG levels to prevent log stampeding in high-volume environments
8
+
5
9
  ### 2.5.1
6
10
 
7
11
  - Ensure `timeout` is an int when passed as a client option to a gRPC client
data/README.md CHANGED
@@ -447,72 +447,8 @@ very large values (such as binary or json data).
447
447
 
448
448
  ## Testing with RSpec
449
449
 
450
- ### Controllers
451
-
452
- In order to test your controller, you first need to mock a GRPC ActiveCall. You can create the following file under `/spec/support/` path of your project:
453
-
454
- ```ruby
455
- require 'grpc'
456
-
457
- module Rpc
458
- module Test
459
- class Call
460
- attr_reader :metadata
461
-
462
- def initialize(md = nil)
463
- @metadata = md || { 'authorization' => "Basic #{Base64.encode64('grpc:magic')}" }
464
- end
465
-
466
- def output_metadata
467
- @output_metadata ||= {}
468
- end
469
- end
470
- end
471
- end
472
- ```
473
-
474
- Imagine you have the following controller to test:
475
-
476
- ```ruby
477
- class ThingController < ::Gruf::Controllers::Base
478
- bind ::Rpc::ThingService::Service
479
-
480
- def get_thing
481
- thing = Rpc::Thing.new(id: request.message.id, name: 'Foo')
482
- Rpc::GetThingResponse.new(thing: thing)
483
- end
484
- end
485
- ```
486
-
487
- You can stub it in the specs this way:
488
-
489
- ```ruby
490
- describe ThingController do
491
- let(:rpc_service) { ::Rpc::ThingService::Service }
492
- let(:rpc_desc) { Rpc::ThingService::Service.rpc_descs.values.first }
493
- let(:message) { Rpc::GetThingRequest.new(id: 1) }
494
- let(:controller) do
495
- described_class.new(
496
- method_key: :get_thing,
497
- service: rpc_service,
498
- active_call: Rpc::Test::Call.new,
499
- message: message,
500
- rpc_desc: rpc_desc
501
- )
502
- end
503
-
504
- describe '.call' do
505
- context 'with :get_thing as an argument' do
506
- let(:result) { controller.call(:get_thing) }
507
-
508
- it 'returns an instance of Rpc::GetThingResponse' do
509
- expect(result).to be_instance_of(Rpc::GetThingResponse)
510
- expect(result.id).to eq request.id
511
- end
512
- end
513
- end
514
- end
515
- ```
450
+ There is a gem specifically for easy testing with RSpec: [gruf-rspec](https://github.com/bigcommerce/gruf-rspec). Take
451
+ a look at its README for more information.
516
452
 
517
453
  ## Plugins
518
454
 
@@ -38,20 +38,22 @@ module Gruf
38
38
  class Interceptor < ::Gruf::Interceptors::ServerInterceptor
39
39
 
40
40
  # Default mappings of codes to log levels...
41
- LOG_LEVEL_MAP = { 'GRPC::Ok' => :info,
42
- 'GRPC::InvalidArgument' => :info,
43
- 'GRPC::NotFound' => :info,
44
- 'GRPC::AlreadyExists' => :info,
45
- 'GRPC::OutOfRange' => :info,
46
- 'GRPC::Unauthenticated' => :warn,
47
- 'GRPC::PermissionDenied' => :warn,
48
- 'GRPC::Unknown' => :error,
49
- 'GRPC::Internal' => :error,
50
- 'GRPC::DataLoss' => :error,
51
- 'GRPC::FailedPrecondition' => :error,
52
- 'GRPC::Unavailable' => :error,
53
- 'GRPC::DeadlineExceeded' => :error,
54
- 'GRPC::Cancelled' => :error }.freeze
41
+ LOG_LEVEL_MAP = {
42
+ 'GRPC::Ok' => :debug,
43
+ 'GRPC::InvalidArgument' => :debug,
44
+ 'GRPC::NotFound' => :debug,
45
+ 'GRPC::AlreadyExists' => :debug,
46
+ 'GRPC::OutOfRange' => :debug,
47
+ 'GRPC::Unauthenticated' => :warn,
48
+ 'GRPC::PermissionDenied' => :warn,
49
+ 'GRPC::Unknown' => :error,
50
+ 'GRPC::Internal' => :error,
51
+ 'GRPC::DataLoss' => :error,
52
+ 'GRPC::FailedPrecondition' => :error,
53
+ 'GRPC::Unavailable' => :error,
54
+ 'GRPC::DeadlineExceeded' => :error,
55
+ 'GRPC::Cancelled' => :error
56
+ }.freeze
55
57
 
56
58
  ###
57
59
  # Log the request, sending it to the appropriate formatter
@@ -70,7 +72,7 @@ module Gruf
70
72
 
71
73
  # A result is either successful, or, some level of feedback handled in the else block...
72
74
  if result.successful?
73
- type = :info
75
+ type = log_level_map['GRPC::Ok'] || :debug
74
76
  status_name = 'GRPC::Ok'
75
77
  else
76
78
  type = log_level_map[result.message_class_name] || :error
@@ -97,7 +99,7 @@ module Gruf
97
99
  payload[:time] = Time.now.to_s
98
100
  payload[:host] = Socket.gethostname
99
101
 
100
- ::Gruf.logger.send(type, formatter.format(payload))
102
+ logger.send(type, formatter.format(payload))
101
103
 
102
104
  raise result.message unless result.successful?
103
105
  result.message
@@ -105,6 +107,13 @@ module Gruf
105
107
 
106
108
  private
107
109
 
110
+ ##
111
+ # @return [::Gruf::Logger]
112
+ #
113
+ def logger
114
+ @logger ||= options.fetch(:logger, ::Gruf.logger)
115
+ end
116
+
108
117
  ##
109
118
  # Return an appropriate log message dependent on the status
110
119
  #
@@ -14,5 +14,5 @@
14
14
  # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
15
  #
16
16
  module Gruf
17
- VERSION = '2.5.1'.freeze
17
+ VERSION = '2.5.2'.freeze
18
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gruf
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.1
4
+ version: 2.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shaun McCormick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-08 00:00:00.000000000 Z
11
+ date: 2019-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -192,8 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
192
  - !ruby/object:Gem::Version
193
193
  version: '0'
194
194
  requirements: []
195
- rubyforge_project:
196
- rubygems_version: 2.7.7
195
+ rubygems_version: 3.0.2
197
196
  signing_key:
198
197
  specification_version: 4
199
198
  summary: gRPC Ruby Framework