grpcx 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a99773353852adc153af1cda72a8c17e980687c69127bb9a7830d983fd4a052d
4
- data.tar.gz: 415a8d6f395db5283f57c9756ed47483560b8b1365ff224090a88f6a5dba02b1
3
+ metadata.gz: 66a39ca3d81a4f36e3ec546252755dc6c8f5a93e77dee26824b935260ced5973
4
+ data.tar.gz: f26e9038ee971c5bd1fcde6be56fc0b19c37e3a195a8474800f5395c18ee0878
5
5
  SHA512:
6
- metadata.gz: 8a92a53f2e0fe302482ca483f4434a35f274045d97ebc77c63e11a425f3c591d31bbcbdec2ed013a0c296fefbaf9ad514ecdc45ad8dbfc9143acde905d767933
7
- data.tar.gz: 775e2e820a35bc874ab36090e3328c72954545653d5dec0a02ee3608aa4b836d88742b17b49a0845dc8e5897db6871464e9978b87f704a03819f23c4bd21971b
6
+ metadata.gz: c90478efde02ea7793cb23a884d3e99ffe4692ed938299da1d391664e18116c3f5c4d938100d9ca0fdd1e56925bd10aba47b3d986b2f0cdb1f93bcef67457c1f
7
+ data.tar.gz: 5c29233c1760993563acc0875792d669505ebd5e18ea4443e441ba807dacd59b5418fa7573834694607abbdddf55b8da1192f40158894e39359dfceea0c593af
@@ -1,9 +1,5 @@
1
1
  inherit_from:
2
- - https://storage.googleapis.com/bsm-misc/rubocop.yml
2
+ - https://gitlab.com/bsm/misc/raw/master/rubocop/default.yml
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 2.2
6
-
7
- Metrics/AbcSize:
8
- Enabled: false
9
-
5
+ TargetRubyVersion: 2.5
@@ -1,70 +1,70 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grpcx (0.2.0)
4
+ grpcx (0.3.0)
5
5
  activesupport (>= 5.0)
6
6
  grpc (>= 1.8.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activemodel (5.2.1)
12
- activesupport (= 5.2.1)
13
- activerecord (5.2.1)
14
- activemodel (= 5.2.1)
15
- activesupport (= 5.2.1)
16
- arel (>= 9.0)
17
- activesupport (5.2.1)
11
+ activemodel (6.0.2.1)
12
+ activesupport (= 6.0.2.1)
13
+ activerecord (6.0.2.1)
14
+ activemodel (= 6.0.2.1)
15
+ activesupport (= 6.0.2.1)
16
+ activesupport (6.0.2.1)
18
17
  concurrent-ruby (~> 1.0, >= 1.0.2)
19
18
  i18n (>= 0.7, < 2)
20
19
  minitest (~> 5.1)
21
20
  tzinfo (~> 1.1)
22
- arel (9.0.0)
21
+ zeitwerk (~> 2.2)
23
22
  ast (2.4.0)
24
- concurrent-ruby (1.0.5)
23
+ concurrent-ruby (1.1.6)
25
24
  diff-lcs (1.3)
26
- google-protobuf (3.6.1)
27
- googleapis-common-protos-types (1.0.2)
25
+ google-protobuf (3.11.4)
26
+ googleapis-common-protos-types (1.0.4)
28
27
  google-protobuf (~> 3.0)
29
- grpc (1.14.2)
30
- google-protobuf (~> 3.1)
31
- googleapis-common-protos-types (~> 1.0.0)
32
- i18n (1.1.0)
28
+ grpc (1.27.0)
29
+ google-protobuf (~> 3.11)
30
+ googleapis-common-protos-types (~> 1.0)
31
+ i18n (1.8.2)
33
32
  concurrent-ruby (~> 1.0)
34
- jaro_winkler (1.5.1)
35
- minitest (5.11.3)
36
- parallel (1.12.1)
37
- parser (2.5.1.2)
33
+ jaro_winkler (1.5.4)
34
+ minitest (5.14.0)
35
+ parallel (1.19.1)
36
+ parser (2.7.0.4)
38
37
  ast (~> 2.4.0)
39
- powerpack (0.1.2)
40
38
  rainbow (3.0.0)
41
- rake (12.3.1)
42
- rspec (3.8.0)
43
- rspec-core (~> 3.8.0)
44
- rspec-expectations (~> 3.8.0)
45
- rspec-mocks (~> 3.8.0)
46
- rspec-core (3.8.0)
47
- rspec-support (~> 3.8.0)
48
- rspec-expectations (3.8.1)
39
+ rake (13.0.1)
40
+ rexml (3.2.4)
41
+ rspec (3.9.0)
42
+ rspec-core (~> 3.9.0)
43
+ rspec-expectations (~> 3.9.0)
44
+ rspec-mocks (~> 3.9.0)
45
+ rspec-core (3.9.1)
46
+ rspec-support (~> 3.9.1)
47
+ rspec-expectations (3.9.0)
49
48
  diff-lcs (>= 1.2.0, < 2.0)
50
- rspec-support (~> 3.8.0)
51
- rspec-mocks (3.8.0)
49
+ rspec-support (~> 3.9.0)
50
+ rspec-mocks (3.9.1)
52
51
  diff-lcs (>= 1.2.0, < 2.0)
53
- rspec-support (~> 3.8.0)
54
- rspec-support (3.8.0)
55
- rubocop (0.59.0)
52
+ rspec-support (~> 3.9.0)
53
+ rspec-support (3.9.2)
54
+ rubocop (0.80.1)
56
55
  jaro_winkler (~> 1.5.1)
57
56
  parallel (~> 1.10)
58
- parser (>= 2.5, != 2.5.1.1)
59
- powerpack (~> 0.1)
57
+ parser (>= 2.7.0.1)
60
58
  rainbow (>= 2.2.2, < 4.0)
59
+ rexml
61
60
  ruby-progressbar (~> 1.7)
62
- unicode-display_width (~> 1.0, >= 1.0.1)
63
- ruby-progressbar (1.10.0)
61
+ unicode-display_width (>= 1.4.0, < 1.7)
62
+ ruby-progressbar (1.10.1)
64
63
  thread_safe (0.3.6)
65
- tzinfo (1.2.5)
64
+ tzinfo (1.2.6)
66
65
  thread_safe (~> 0.1)
67
- unicode-display_width (1.4.0)
66
+ unicode-display_width (1.6.1)
67
+ zeitwerk (2.3.0)
68
68
 
69
69
  PLATFORMS
70
70
  ruby
@@ -78,4 +78,4 @@ DEPENDENCIES
78
78
  rubocop
79
79
 
80
80
  BUNDLED WITH
81
- 1.16.4
81
+ 2.1.4
data/README.md CHANGED
@@ -50,37 +50,11 @@ end
50
50
 
51
51
  ## Using with [Datadog::Notifications](https://github.com/bsm/datadog-notifications)
52
52
 
53
- ```ruby
54
- # TODO: update this in datadog-notifications gem itself (to handle new service/action payloads)
55
- module Datadog::Notifications::Plugins
56
- class MyGRPC < Base
57
-
58
- def initialize(opts={})
59
- super
60
- Datadog::Notifications.subscribe(Grpcx::Server::Interceptors::Instrumentation::METRIC_NAME) do |reporter, event|
61
- record(reporter, event)
62
- end
63
- end
64
-
65
- private
66
-
67
- def record(reporter, event)
68
- service = event.payload[:service]
69
- action = event.payload[:action]
70
- status = event.payload[:exception] ? 'error' : 'ok'
71
- tags = self.tags + %W[service:#{service} action:#{action} status:#{status}]
72
-
73
- reporter.batch do
74
- reporter.increment 'grpc.request', tags: tags
75
- reporter.timing 'grpc.request.time', event.duration, tags: tags
76
- end
77
- end
78
-
79
- end
80
- end
53
+ Since version >= [0.5.4](https://github.com/bsm/datadog-notifications/releases/tag/v0.5.4)
81
54
 
55
+ ```ruby
82
56
  Datadog::Notifications.configure do |c|
83
- c.use Datadog::Notifications::Plugins::MyGRPC
57
+ c.use Datadog::Notifications::Plugins::GRPC
84
58
  end if RUNNING_IN_PROD?
85
59
  ```
86
60
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'grpcx'
3
- s.version = '0.2.0'
3
+ s.version = '0.3.0'
4
4
  s.authors = ['Black Square Media Ltd']
5
5
  s.email = ['info@blacksquaremedia.com']
6
6
  s.summary = %(gRPC extensions/helpers)
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.files = `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^spec/}) }
12
12
  s.test_files = `git ls-files -z -- spec/*`.split("\x0")
13
13
  s.require_paths = ['lib']
14
- s.required_ruby_version = '>= 2.2'
14
+ s.required_ruby_version = '>= 2.5'
15
15
 
16
16
  s.add_dependency 'activesupport', '>= 5.0'
17
17
  s.add_dependency 'grpc', '>= 1.8.0'
@@ -10,11 +10,11 @@ module Grpcx
10
10
 
11
11
  module_function
12
12
 
13
- TRUE_VALUES = [true, 1, "1", "t", "T", "true", "TRUE", "on", "ON"].to_set.freeze
13
+ TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE', 'on', 'ON'].to_set.freeze
14
14
 
15
15
  # @param [Class] msgclass messagepack message class
16
16
  # @param [Hash] attrs attributes to assign
17
- def build(msgclass, attrs={}) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
17
+ def build(msgclass, attrs = {}) # rubocop:disable Metrics/MethodLength
18
18
  attrs = ActiveSupport::HashWithIndifferentAccess.new(attrs)
19
19
  fields = {}
20
20
  msgclass.descriptor.each do |field| # rubocop:disable Metrics/BlockLength
@@ -22,7 +22,7 @@ module Grpcx
22
22
  end
23
23
  end
24
24
 
25
- def initialize(opts={})
25
+ def initialize(opts = {})
26
26
  opts[:pool_size] ||= ENV['GRPC_SERVER_THREADS'].to_i if ENV['GRPC_SERVER_THREADS']
27
27
  opts[:max_waiting_requests] ||= ENV['GRPC_SERVER_QUEUE'].to_i if ENV['GRPC_SERVER_QUEUE']
28
28
 
@@ -5,7 +5,6 @@ module Grpcx
5
5
  # making sure that connection is established before each request
6
6
  # and re-pooling connections when request is processed.
7
7
  class ActiveRecord < GRPC::ServerInterceptor
8
-
9
8
  def request_response(*, &block)
10
9
  wrap(&block)
11
10
  end
@@ -30,7 +29,6 @@ module Grpcx
30
29
  ensure
31
30
  ::ActiveRecord::Base.clear_active_connections!
32
31
  end
33
-
34
32
  end
35
33
  end
36
34
  end
@@ -6,19 +6,19 @@ module Grpcx
6
6
  class Instrumentation < GRPC::ServerInterceptor
7
7
  METRIC_NAME = 'process_action.grpc'.freeze
8
8
 
9
- def request_response(opts={}, &block)
9
+ def request_response(opts = {}, &block)
10
10
  instrument(opts[:method], &block)
11
11
  end
12
12
 
13
- def client_streamer(opts={}, &block)
13
+ def client_streamer(opts = {}, &block)
14
14
  instrument(opts[:method], &block)
15
15
  end
16
16
 
17
- def server_streamer(opts={}, &block)
17
+ def server_streamer(opts = {}, &block)
18
18
  instrument(opts[:method], &block)
19
19
  end
20
20
 
21
- def bidi_streamer(opts={}, &block)
21
+ def bidi_streamer(opts = {}, &block)
22
22
  instrument(opts[:method], &block)
23
23
  end
24
24
 
@@ -29,7 +29,6 @@ module Grpcx
29
29
  action = method.name # does not match real proto service name; it's a GRPC::GenericService.underscore-d version
30
30
  ActiveSupport::Notifications.instrument(METRIC_NAME, service: service, action: action, &block)
31
31
  end
32
-
33
32
  end
34
33
  end
35
34
  end
@@ -2,35 +2,34 @@ module Grpcx
2
2
  module Server
3
3
  module Interceptors
4
4
  class Rescue < GRPC::ServerInterceptor
5
- def initialize(rescuable, opts={})
5
+ def initialize(rescuable, opts = {})
6
6
  @rescuable = rescuable
7
7
  super(opts)
8
8
  end
9
9
 
10
10
  def request_response(*)
11
11
  yield
12
- rescue StandardError => err
13
- @rescuable.rescue_with_handler(err) || raise
12
+ rescue StandardError => e
13
+ @rescuable.rescue_with_handler(e) || raise
14
14
  end
15
15
 
16
16
  def client_streamer(*)
17
17
  yield
18
- rescue StandardError => err
19
- @rescuable.rescue_with_handler(err) || raise
18
+ rescue StandardError => e
19
+ @rescuable.rescue_with_handler(e) || raise
20
20
  end
21
21
 
22
22
  def server_streamer(*)
23
23
  yield
24
- rescue StandardError => err
25
- @rescuable.rescue_with_handler(err) || raise
24
+ rescue StandardError => e
25
+ @rescuable.rescue_with_handler(e) || raise
26
26
  end
27
27
 
28
28
  def bidi_streamer(*)
29
29
  yield
30
- rescue StandardError => err
31
- @rescuable.rescue_with_handler(err) || raise
30
+ rescue StandardError => e
31
+ @rescuable.rescue_with_handler(e) || raise
32
32
  end
33
-
34
33
  end
35
34
  end
36
35
  end
@@ -1,19 +1,18 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe Grpcx::Entity do
4
-
5
4
  it 'should build messages' do
6
5
  msg = described_class.build Grpcx::Spec::Message,
7
- name: 'Name',
8
- version: 1,
9
- types: {
10
- num: 8,
11
- truth: [1, 0, true, 'true'],
12
- decimal: '1.2',
13
- }
6
+ name: 'Name',
7
+ version: 1,
8
+ types: {
9
+ num: 8,
10
+ truth: [1, 0, true, 'true'],
11
+ decimal: '1.2',
12
+ }
14
13
 
15
14
  expect(msg.to_h).to eq(
16
- name: "Name",
15
+ name: 'Name',
17
16
  version: :V1,
18
17
  types: {
19
18
  num: 8,
@@ -22,5 +21,4 @@ RSpec.describe Grpcx::Entity do
22
21
  },
23
22
  )
24
23
  end
25
-
26
24
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe Grpcx::Server do
4
-
5
4
  subject do
6
5
  s = Grpcx::Spec::Server.new
7
6
  s.handle Grpcx::Spec::Service::V1
@@ -31,5 +30,4 @@ RSpec.describe Grpcx::Server do
31
30
  ArgumentError
32
31
  ]
33
32
  end
34
-
35
33
  end
@@ -4,30 +4,30 @@ require 'active_record'
4
4
  require 'google/protobuf'
5
5
 
6
6
  Google::Protobuf::DescriptorPool.generated_pool.build do
7
- add_message "grpcx.spec.Message" do
7
+ add_message 'grpcx.spec.Message' do
8
8
  optional :name, :string, 1
9
- optional :version, :enum, 2, "grpcx.spec.Version"
10
- optional :types, :message, 3, "grpcx.spec.Types"
9
+ optional :version, :enum, 2, 'grpcx.spec.Version'
10
+ optional :types, :message, 3, 'grpcx.spec.Types'
11
11
  end
12
- add_message "grpcx.spec.Types" do
12
+ add_message 'grpcx.spec.Types' do
13
13
  optional :num, :int64, 1
14
14
  repeated :truth, :bool, 2
15
15
  optional :decimal, :double, 3
16
16
  end
17
- add_enum "grpcx.spec.Version" do
17
+ add_enum 'grpcx.spec.Version' do
18
18
  value :V0, 0
19
19
  value :V1, 1
20
20
  value :V2, 2
21
21
  end
22
- add_message "grpcx.spec.GetMessageRequest" do
22
+ add_message 'grpcx.spec.GetMessageRequest' do
23
23
  end
24
24
  end
25
25
 
26
26
  module Grpcx::Spec
27
- Message = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpcx.spec.Message").msgclass
28
- Version = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpcx.spec.Version").enummodule
29
- Types = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpcx.spec.Types").msgclass
30
- GetMessageRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpcx.spec.GetMessageRequest").msgclass
27
+ Message = Google::Protobuf::DescriptorPool.generated_pool.lookup('grpcx.spec.Message').msgclass
28
+ Version = Google::Protobuf::DescriptorPool.generated_pool.lookup('grpcx.spec.Version').enummodule
29
+ Types = Google::Protobuf::DescriptorPool.generated_pool.lookup('grpcx.spec.Types').msgclass
30
+ GetMessageRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup('grpcx.spec.GetMessageRequest').msgclass
31
31
 
32
32
  module Service
33
33
  class V1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grpcx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Black Square Media Ltd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-10 00:00:00.000000000 Z
11
+ date: 2020-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -145,15 +145,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
145
  requirements:
146
146
  - - ">="
147
147
  - !ruby/object:Gem::Version
148
- version: '2.2'
148
+ version: '2.5'
149
149
  required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  requirements:
151
151
  - - ">="
152
152
  - !ruby/object:Gem::Version
153
153
  version: '0'
154
154
  requirements: []
155
- rubyforge_project:
156
- rubygems_version: 2.7.6
155
+ rubygems_version: 3.0.6
157
156
  signing_key:
158
157
  specification_version: 4
159
158
  summary: gRPC extensions/helpers