hanami-events-cloud_pubsub 3.0.2 → 3.0.7

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: 37d3b5fbc39d5156f61b017e935a4695ad39bb6e10ed435554d1f376fda584f9
4
- data.tar.gz: 35416fe9cca3d8eefa03fd998bbe2030163aa59d4cfe88c4eba465d867355bf5
3
+ metadata.gz: c9761e02377d807f35d3c4e005d4948237bf89204ba7d7dc619d46e91d7bca38
4
+ data.tar.gz: fade5b3c8657111ab4e485ad5b03bb584b69d4557cd2416d5e0c358bcf5dc3f4
5
5
  SHA512:
6
- metadata.gz: 36a700e7622f60bdef194ed6f7041967cded5e7fbd16b83b2b0d1f10f574a1774bcf6e40c63fd29b12b8a0ee078d14fac48a0149420a89481f7b779674a063aa
7
- data.tar.gz: '0619ed7a378a522575aa9eeb096f51058e69f3027cc9c7d3d0ad312315366bec1e2f380698ae7747fdbb92a87d77ca6c4f27bb625da9088885cf32db3e7875d1'
6
+ metadata.gz: c89ad6a21c559f77c671b10cd7da95bbd7fbf09a5b0489615e46338677cac4cab129faa2b8e8d69faf6f762cda00d9b0bbf261dd82998634ebc7702e55c4ddb3
7
+ data.tar.gz: 0c785630df1938f248a4c5fc2f5ad5470ea8f75e872dada244dcc0229bedebbf8214ee98cbe28c5b745ba8037ce8d40ea48bafea028dc2e30329e01e6f7d623c
@@ -0,0 +1,47 @@
1
+ ---
2
+ name: CI
3
+ on: [push, pull_request]
4
+ env:
5
+ CC_TEST_REPORTER_ID: "7ab310950456b913cd7e947f6671e3e9c16822f33bd8c572dadcc14593fe4fb5"
6
+ COVERAGE: "true"
7
+ jobs:
8
+ test:
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ ruby: ["2.5", "2.6", "2.7"]
13
+
14
+ runs-on: ubuntu-latest
15
+
16
+ steps:
17
+ - uses: actions/checkout@v2
18
+
19
+ - uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: ${{ matrix.ruby }}
22
+ bundler-cache: true
23
+
24
+ - name: Set ENV for codeclimate (pull_request)
25
+ run: |
26
+ git fetch --no-tags --prune --depth=1 origin +refs/heads/$GITHUB_HEAD_REF:refs/remotes/origin/$GITHUB_HEAD_REF
27
+ echo "GIT_BRANCH=$GITHUB_HEAD_REF" >> $GITHUB_ENV
28
+ echo "GIT_COMMIT_SHA=$(git rev-parse origin/$GITHUB_HEAD_REF)" >> $GITHUB_ENV
29
+ if: github.event_name == 'pull_request'
30
+
31
+ - name: Set ENV for codeclimate (push)
32
+ run: |
33
+ echo "GIT_BRANCH=$GITHUB_REF" >> $GITHUB_ENV
34
+ echo "GIT_COMMIT_SHA=$GITHUB_SHA" >> $GITHUB_ENV
35
+ if: github.event_name == 'push'
36
+
37
+ - name: Prepare for test
38
+ run: |
39
+ curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
40
+ chmod +x ./cc-test-reporter
41
+ ./cc-test-reporter before-build
42
+
43
+ - name: Run tests
44
+ run: bundle exec rake
45
+
46
+ - name: Report coverage
47
+ run: ./cc-test-reporter after-build -t simplecov --exit-code $?
data/.gitignore CHANGED
@@ -11,3 +11,4 @@
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
13
  coverage
14
+ Gemfile.lock
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2020-09-25 19:54:44 UTC using RuboCop version 0.89.0.
3
+ # on 2020-12-08 03:28:27 UTC using RuboCop version 0.89.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -15,13 +15,23 @@ Lint/RedundantCopDisableDirective:
15
15
  # Offense count: 3
16
16
  # Configuration parameters: IgnoredMethods.
17
17
  Metrics/AbcSize:
18
- Max: 21
18
+ Max: 25
19
+
20
+ # Offense count: 1
21
+ # Configuration parameters: IgnoredMethods.
22
+ Metrics/CyclomaticComplexity:
23
+ Max: 11
19
24
 
20
25
  # Offense count: 4
21
26
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
22
27
  Metrics/MethodLength:
23
28
  Max: 14
24
29
 
30
+ # Offense count: 1
31
+ # Configuration parameters: IgnoredMethods.
32
+ Metrics/PerceivedComplexity:
33
+ Max: 11
34
+
25
35
  # Offense count: 1
26
36
  # Configuration parameters: AllowedVariables.
27
37
  Style/GlobalVars:
data/Gemfile CHANGED
@@ -7,9 +7,11 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
7
7
  # Specify your gem's dependencies in hanami-events-cloud_pubsub.gemspec
8
8
  gemspec
9
9
 
10
+ RUBY_MAJOR = RUBY_VERSION[0].to_i
11
+
10
12
  gem 'hanami-events', github: 'hanami/events'
11
13
  gem 'pry'
12
14
  gem 'rubocop'
13
15
  gem 'simplecov', require: false
14
-
15
16
  gem 'request_id', '~> 0.4.3'
17
+ gem 'webrick' if RUBY_MAJOR > 2
@@ -26,12 +26,12 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.add_dependency 'dry-configurable', '>= 0.8'
28
28
  spec.add_dependency 'gapic-common', '>= 0.3.4'
29
- spec.add_dependency 'google-cloud-pubsub', '>= 0.38.1', '< 2.1'
29
+ spec.add_dependency 'google-cloud-pubsub', '>= 0.38.1', '< 2.4'
30
30
  spec.add_dependency 'hanami-cli', '~> 0.2'
31
31
  spec.add_dependency 'hanami-events', '~> 0.2.0'
32
32
  spec.add_dependency 'rack'
33
33
 
34
- spec.add_development_dependency 'bundler', '~> 1.16'
34
+ spec.add_development_dependency 'bundler', '~> 2.1'
35
35
  spec.add_development_dependency 'prometheus-client'
36
36
  spec.add_development_dependency 'rake', '~> 13.0'
37
37
  spec.add_development_dependency 'rspec', '~> 3.0'
@@ -52,7 +52,7 @@ module Hanami
52
52
  }, reader: true
53
53
  setting :error_handlers, [
54
54
  ->(err, msg) do
55
- logger.error "Message(#{msg.message_id}) failed with exception #{err.inspect}"
55
+ logger.error "Message(#{msg}) failed with exception #{err.inspect}"
56
56
  end
57
57
  ], reader: true
58
58
 
@@ -50,6 +50,7 @@ module Hanami
50
50
  end
51
51
 
52
52
  def setup_env(opts)
53
+ Process.setproctitle('hanami-events-cloud_pubsub')
53
54
  ENV['PUBSUB_EMULATOR_HOST'] ||= 'localhost:8085' if opts[:emulator]
54
55
  end
55
56
 
@@ -59,7 +59,8 @@ module Hanami
59
59
  end
60
60
 
61
61
  def shutdown
62
- subscriber.stop.wait!
62
+ stop
63
+ wait
63
64
  self
64
65
  end
65
66
 
@@ -68,8 +69,8 @@ module Hanami
68
69
  self
69
70
  end
70
71
 
71
- def wait
72
- subscriber.wait!
72
+ def wait(timeout = 60)
73
+ subscriber.wait!(timeout)
73
74
  self
74
75
  end
75
76
 
@@ -87,7 +88,7 @@ module Hanami
87
88
  middleware.invoke(message) { handler.call(message) }
88
89
  message.ack!
89
90
  rescue StandardError => e
90
- run_error_handlers(e, message)
91
+ run_error_handlers(e, message.message_id.to_s)
91
92
  message.nack! if CloudPubsub.config.auto_retry.enabled
92
93
  raise
93
94
  end
@@ -133,16 +134,25 @@ module Hanami
133
134
  end
134
135
 
135
136
  def apply_retry_options(sub)
136
- return {} unless CloudPubsub.config.auto_retry.enabled
137
+ retry_policy = build_retry_policy
138
+ attempts = CloudPubsub.config.auto_retry.max_attempts
137
139
 
138
- sub.retry_policy = Google::Cloud::PubSub::RetryPolicy.new(
140
+ sub.retry_policy = retry_policy if sub.retry_policy&.to_grpc != retry_policy&.to_grpc
141
+ sub.dead_letter_topic = dead_letter_topic if sub.dead_letter_topic&.name != dead_letter_topic&.name
142
+ sub.dead_letter_max_delivery_attempts = attempts if sub.dead_letter_topic&.name != dead_letter_topic&.name
143
+
144
+ sub
145
+ rescue StandardError => e
146
+ run_error_handlers(e, nil)
147
+ end
148
+
149
+ def build_retry_policy
150
+ return unless CloudPubsub.config.auto_retry.enabled
151
+
152
+ Google::Cloud::PubSub::RetryPolicy.new(
139
153
  minimum_backoff: CloudPubsub.config.auto_retry.minimum_backoff,
140
154
  maximum_backoff: CloudPubsub.config.auto_retry.maximum_backoff
141
155
  )
142
- sub.dead_letter_topic = dead_letter_topic
143
- sub.dead_letter_max_delivery_attempts = CloudPubsub.config.auto_retry.max_attempts
144
-
145
- sub
146
156
  end
147
157
  end
148
158
  # rubocop:enable Metrics/ClassLength:
@@ -9,7 +9,7 @@ module Hanami
9
9
  class Runner
10
10
  attr_reader :logger, :adapter
11
11
 
12
- def initialize(adapter:, logger:, sleep_time: 2)
12
+ def initialize(adapter:, logger:, sleep_time: 30)
13
13
  @logger = logger
14
14
  @adapter = adapter
15
15
  @sleep_time = sleep_time
@@ -40,9 +40,8 @@ module Hanami
40
40
  def gracefully_shutdown
41
41
  stop
42
42
  logger.info "Gracefully shutting down CloudPubsub runner: #{self}"
43
- sleep_for_a_bit
43
+ adapter.listeners.each { |l| l.wait(@sleep_time) }
44
44
  adapter.flush_messages
45
- adapter.listeners.each(&:wait)
46
45
  handle_on_shutdown
47
46
 
48
47
  self
@@ -102,10 +101,6 @@ module Hanami
102
101
  MSG
103
102
  end
104
103
 
105
- def sleep_for_a_bit
106
- sleep @sleep_time
107
- end
108
-
109
104
  def handle_on_shutdown
110
105
  return if CloudPubsub.on_shutdown_handlers.empty?
111
106
 
@@ -3,7 +3,7 @@
3
3
  module Hanami
4
4
  module Events
5
5
  module CloudPubsub
6
- VERSION = '3.0.2'
6
+ VERSION = '3.0.7'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-events-cloud_pubsub
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Ker-Seymer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-30 00:00:00.000000000 Z
11
+ date: 2021-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable
@@ -47,7 +47,7 @@ dependencies:
47
47
  version: 0.38.1
48
48
  - - "<"
49
49
  - !ruby/object:Gem::Version
50
- version: '2.1'
50
+ version: '2.4'
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
@@ -57,7 +57,7 @@ dependencies:
57
57
  version: 0.38.1
58
58
  - - "<"
59
59
  - !ruby/object:Gem::Version
60
- version: '2.1'
60
+ version: '2.4'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: hanami-cli
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -106,14 +106,14 @@ dependencies:
106
106
  requirements:
107
107
  - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: '1.16'
109
+ version: '2.1'
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
- version: '1.16'
116
+ version: '2.1'
117
117
  - !ruby/object:Gem::Dependency
118
118
  name: prometheus-client
119
119
  requirement: !ruby/object:Gem::Requirement
@@ -164,15 +164,14 @@ executables:
164
164
  extensions: []
165
165
  extra_rdoc_files: []
166
166
  files:
167
+ - ".github/workflows/ci.yml"
167
168
  - ".gitignore"
168
169
  - ".rspec"
169
170
  - ".rubocop.yml"
170
171
  - ".rubocop_todo.yml"
171
172
  - ".tool-versions"
172
- - ".travis.yml"
173
173
  - CODE_OF_CONDUCT.md
174
174
  - Gemfile
175
- - Gemfile.lock
176
175
  - LICENSE.txt
177
176
  - README.md
178
177
  - Rakefile
data/.travis.yml DELETED
@@ -1,32 +0,0 @@
1
- ---
2
- sudo: required
3
- cache: bundler
4
- services:
5
- - docker
6
- language: ruby
7
- env:
8
- global:
9
- - CC_TEST_REPORTER_ID=7ab310950456b913cd7e947f6671e3e9c16822f33bd8c572dadcc14593fe4fb5
10
- - COVERAGE=true
11
- rvm:
12
- - 2.5
13
- - 2.6
14
- - 2.7
15
- before_install:
16
- - gem install bundler -v 1.16.1
17
- before_script:
18
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
19
- - chmod +x ./cc-test-reporter
20
- - ./cc-test-reporter before-build
21
- after_script:
22
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
23
- after_failure:
24
- - cat log/test.log
25
- deploy:
26
- provider: rubygems
27
- api_key:
28
- secure: q/B3zDEld8yzf1plU1vlnUIhqk7hhdrqdF8uRnSvikweM9MSeGk1x6lcZ4mxnwCVPuQEP49iI4sNtFHiJnP/Dv6f48A6ltpVlyST1vghhXlaIi9+r9pCJqB+vAOii7poq9lWyKWj15MMB5xE52Alz7WzUccOL55gmJ4q+Lia6+z04m+VdOuEY1Lyn38O9jtZJBBfnbjar+qKoHXCNSKuJfXrFBi+2LKvaxJFWS8NBvhnDILNkcooh01rp6/dtNuUMFTLd1i+zMMBYc1PyGP0+fNZE9MXUViy3soDfgXlPDyiwtTzASLCu6HXQg8g9SwBxMnkRQRxAKYzoAPoECcr9NxMR1riH6xaA2wkwW/rKcBP5JPfbRymRgSui4uhYSq7WJR5KNxpH2JYK+rW/EL9SB+7BT67g3ZNL6YGpL3R7/S5RLdHk+lJIY8uFRtzhYgchSa0tkBAm/qbll5d4B9wq7O1/McNwUQJKFs7CsVXL/arZUFgQVGdkQDOIeCITzeFy4iP3JASewOk+yCUyCbBCya2AicU7BOjYpghD0QNmyaunTPhCySdBe4mS3QkAspHGg10H5dggNS0IqHYmUTlmHiYg9Pf9TF85krQih/s3hr/+i13u+y8iBwA7n/mXTt5IQ+NQgXNSC0uJvSjHU2Rzr9yKZ1lLEXMB0y+S9OVeZA=
29
- gem: hanami-events-cloud_pubsub
30
- on:
31
- tags: true
32
- repo: adHawk/hanami-events-cloud_pubsub
data/Gemfile.lock DELETED
@@ -1,161 +0,0 @@
1
- GIT
2
- remote: https://github.com/hanami/events
3
- revision: 59a36d22b75ea045fa8994f4f660a02c0901f8b2
4
- specs:
5
- hanami-events (0.2.1)
6
- dry-container (~> 0.6)
7
-
8
- PATH
9
- remote: .
10
- specs:
11
- hanami-events-cloud_pubsub (3.0.2)
12
- dry-configurable (>= 0.8)
13
- gapic-common (>= 0.3.4)
14
- google-cloud-pubsub (>= 0.38.1, < 2.1)
15
- hanami-cli (~> 0.2)
16
- hanami-events (~> 0.2.0)
17
- rack
18
-
19
- GEM
20
- remote: https://rubygems.org/
21
- specs:
22
- addressable (2.7.0)
23
- public_suffix (>= 2.0.2, < 5.0)
24
- ast (2.4.1)
25
- coderay (1.1.3)
26
- concurrent-ruby (1.1.6)
27
- diff-lcs (1.4.4)
28
- docile (1.3.2)
29
- dry-configurable (0.11.6)
30
- concurrent-ruby (~> 1.0)
31
- dry-core (~> 0.4, >= 0.4.7)
32
- dry-equalizer (~> 0.2)
33
- dry-container (0.7.2)
34
- concurrent-ruby (~> 1.0)
35
- dry-configurable (~> 0.1, >= 0.1.3)
36
- dry-core (0.4.9)
37
- concurrent-ruby (~> 1.0)
38
- dry-equalizer (0.3.0)
39
- faraday (1.0.1)
40
- multipart-post (>= 1.2, < 3)
41
- gapic-common (0.3.4)
42
- google-protobuf (~> 3.12, >= 3.12.2)
43
- googleapis-common-protos (>= 1.3.9, < 2.0)
44
- googleapis-common-protos-types (>= 1.0.4, < 2.0)
45
- googleauth (~> 0.9)
46
- grpc (~> 1.25)
47
- google-cloud-core (1.5.0)
48
- google-cloud-env (~> 1.0)
49
- google-cloud-errors (~> 1.0)
50
- google-cloud-env (1.3.3)
51
- faraday (>= 0.17.3, < 2.0)
52
- google-cloud-errors (1.0.1)
53
- google-cloud-pubsub (2.0.0)
54
- concurrent-ruby (~> 1.1)
55
- google-cloud-core (~> 1.5)
56
- google-cloud-pubsub-v1 (~> 0.0)
57
- google-cloud-pubsub-v1 (0.1.2)
58
- gapic-common (~> 0.3)
59
- google-cloud-errors (~> 1.0)
60
- grpc-google-iam-v1 (>= 0.6.10, < 2.0)
61
- google-protobuf (3.13.0)
62
- googleapis-common-protos (1.3.10)
63
- google-protobuf (~> 3.11)
64
- googleapis-common-protos-types (>= 1.0.5, < 2.0)
65
- grpc (~> 1.27)
66
- googleapis-common-protos-types (1.0.5)
67
- google-protobuf (~> 3.11)
68
- googleauth (0.13.1)
69
- faraday (>= 0.17.3, < 2.0)
70
- jwt (>= 1.4, < 3.0)
71
- memoist (~> 0.16)
72
- multi_json (~> 1.11)
73
- os (>= 0.9, < 2.0)
74
- signet (~> 0.14)
75
- grpc (1.32.0)
76
- google-protobuf (~> 3.13)
77
- googleapis-common-protos-types (~> 1.0)
78
- grpc-google-iam-v1 (0.6.10)
79
- google-protobuf (~> 3.11)
80
- googleapis-common-protos (>= 1.3.10, < 2.0)
81
- grpc (~> 1.27)
82
- hanami-cli (0.3.1)
83
- concurrent-ruby (~> 1.0)
84
- hanami-utils (~> 1.3)
85
- hanami-utils (1.3.6)
86
- concurrent-ruby (~> 1.0)
87
- transproc (~> 1.0)
88
- jwt (2.2.2)
89
- memoist (0.16.2)
90
- method_source (1.0.0)
91
- multi_json (1.15.0)
92
- multipart-post (2.1.1)
93
- os (1.1.1)
94
- parallel (1.19.2)
95
- parser (2.7.1.4)
96
- ast (~> 2.4.1)
97
- prometheus-client (2.1.0)
98
- pry (0.13.1)
99
- coderay (~> 1.1)
100
- method_source (~> 1.0)
101
- public_suffix (4.0.6)
102
- rack (2.2.3)
103
- rainbow (3.0.0)
104
- rake (13.0.1)
105
- regexp_parser (1.7.1)
106
- request_id (0.4.3)
107
- rexml (3.2.4)
108
- rspec (3.9.0)
109
- rspec-core (~> 3.9.0)
110
- rspec-expectations (~> 3.9.0)
111
- rspec-mocks (~> 3.9.0)
112
- rspec-core (3.9.2)
113
- rspec-support (~> 3.9.3)
114
- rspec-expectations (3.9.2)
115
- diff-lcs (>= 1.2.0, < 2.0)
116
- rspec-support (~> 3.9.0)
117
- rspec-mocks (3.9.1)
118
- diff-lcs (>= 1.2.0, < 2.0)
119
- rspec-support (~> 3.9.0)
120
- rspec-support (3.9.3)
121
- rubocop (0.89.0)
122
- parallel (~> 1.10)
123
- parser (>= 2.7.1.1)
124
- rainbow (>= 2.2.2, < 4.0)
125
- regexp_parser (>= 1.7)
126
- rexml
127
- rubocop-ast (>= 0.1.0, < 1.0)
128
- ruby-progressbar (~> 1.7)
129
- unicode-display_width (>= 1.4.0, < 2.0)
130
- rubocop-ast (0.3.0)
131
- parser (>= 2.7.1.4)
132
- ruby-progressbar (1.10.1)
133
- signet (0.14.0)
134
- addressable (~> 2.3)
135
- faraday (>= 0.17.3, < 2.0)
136
- jwt (>= 1.5, < 3.0)
137
- multi_json (~> 1.10)
138
- simplecov (0.18.5)
139
- docile (~> 1.1)
140
- simplecov-html (~> 0.11)
141
- simplecov-html (0.12.2)
142
- transproc (1.1.1)
143
- unicode-display_width (1.7.0)
144
-
145
- PLATFORMS
146
- ruby
147
-
148
- DEPENDENCIES
149
- bundler (~> 1.16)
150
- hanami-events!
151
- hanami-events-cloud_pubsub!
152
- prometheus-client
153
- pry
154
- rake (~> 13.0)
155
- request_id (~> 0.4.3)
156
- rspec (~> 3.0)
157
- rubocop
158
- simplecov
159
-
160
- BUNDLED WITH
161
- 1.17.3