hanami-events-cloud_pubsub 3.0.1 → 3.0.6

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: 9ed996f19617d35dea1812cfe7de9c53add0a7be29a25cf6735f264754f8c46c
4
- data.tar.gz: 85d62a2346e2260bc46402e7fa15a894e28c7b7b7d5b85dd7b4aa24ceaa62506
3
+ metadata.gz: 0c771a179c93a8264e30f783a31b3c623c301206c587f9fb76f3dfcff9834731
4
+ data.tar.gz: 6b4b4ec5bbef668fc5fdf3d46a336a1646a440eeaeb68825803211dc6797ac34
5
5
  SHA512:
6
- metadata.gz: 641c25a25fad9f9d5408818719b72d3035f9b0fcd0d162f32dab7c0c9868bf3db2c74beae12821e9fb792f19d6bcc4005854e5ee346e18415e689ecdcbc25459
7
- data.tar.gz: 56911f5ab294af2ed08a30e4e1b5e1f947e130a7d8229073ae195ab538e2d63a36dab0260410707c64264175667781bb41c93da722174dbe56c86f115d7c77e5
6
+ metadata.gz: dd9fdb68cd1a9bfffadd5a55e3656c39e884dfa99f57324dba5b2609309c3077e8a83ed6d9bfe169dd5cf4ead82ab1fbe38c057ac889ae099f7f54aad8304aa0
7
+ data.tar.gz: 339896e5b18a3396f6988c19b846f6995d1fc3368b5430ff25c5ef5a759c9beac1609715aa2221ce03ea7470c3f769a4b8035a6fdb1198dd420fb4d619ba432f
@@ -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:
@@ -8,10 +8,10 @@ GIT
8
8
  PATH
9
9
  remote: .
10
10
  specs:
11
- hanami-events-cloud_pubsub (3.0.1)
11
+ hanami-events-cloud_pubsub (3.0.6)
12
12
  dry-configurable (>= 0.8)
13
13
  gapic-common (>= 0.3.4)
14
- google-cloud-pubsub (>= 0.38.1, < 2.1)
14
+ google-cloud-pubsub (>= 0.38.1, < 2.4)
15
15
  hanami-cli (~> 0.2)
16
16
  hanami-events (~> 0.2.0)
17
17
  rack
@@ -36,8 +36,9 @@ GEM
36
36
  dry-core (0.4.9)
37
37
  concurrent-ruby (~> 1.0)
38
38
  dry-equalizer (0.3.0)
39
- faraday (1.0.1)
39
+ faraday (1.1.0)
40
40
  multipart-post (>= 1.2, < 3)
41
+ ruby2_keywords
41
42
  gapic-common (0.3.4)
42
43
  google-protobuf (~> 3.12, >= 3.12.2)
43
44
  googleapis-common-protos (>= 1.3.9, < 2.0)
@@ -47,10 +48,10 @@ GEM
47
48
  google-cloud-core (1.5.0)
48
49
  google-cloud-env (~> 1.0)
49
50
  google-cloud-errors (~> 1.0)
50
- google-cloud-env (1.3.3)
51
+ google-cloud-env (1.4.0)
51
52
  faraday (>= 0.17.3, < 2.0)
52
53
  google-cloud-errors (1.0.1)
53
- google-cloud-pubsub (2.0.0)
54
+ google-cloud-pubsub (2.3.0)
54
55
  concurrent-ruby (~> 1.1)
55
56
  google-cloud-core (~> 1.5)
56
57
  google-cloud-pubsub-v1 (~> 0.0)
@@ -58,21 +59,21 @@ GEM
58
59
  gapic-common (~> 0.3)
59
60
  google-cloud-errors (~> 1.0)
60
61
  grpc-google-iam-v1 (>= 0.6.10, < 2.0)
61
- google-protobuf (3.13.0)
62
+ google-protobuf (3.14.0)
62
63
  googleapis-common-protos (1.3.10)
63
64
  google-protobuf (~> 3.11)
64
65
  googleapis-common-protos-types (>= 1.0.5, < 2.0)
65
66
  grpc (~> 1.27)
66
67
  googleapis-common-protos-types (1.0.5)
67
68
  google-protobuf (~> 3.11)
68
- googleauth (0.13.1)
69
+ googleauth (0.14.0)
69
70
  faraday (>= 0.17.3, < 2.0)
70
71
  jwt (>= 1.4, < 3.0)
71
72
  memoist (~> 0.16)
72
73
  multi_json (~> 1.11)
73
74
  os (>= 0.9, < 2.0)
74
75
  signet (~> 0.14)
75
- grpc (1.32.0)
76
+ grpc (1.34.0)
76
77
  google-protobuf (~> 3.13)
77
78
  googleapis-common-protos-types (~> 1.0)
78
79
  grpc-google-iam-v1 (0.6.10)
@@ -130,6 +131,7 @@ GEM
130
131
  rubocop-ast (0.3.0)
131
132
  parser (>= 2.7.1.4)
132
133
  ruby-progressbar (1.10.1)
134
+ ruby2_keywords (0.0.2)
133
135
  signet (0.14.0)
134
136
  addressable (~> 2.3)
135
137
  faraday (>= 0.17.3, < 2.0)
@@ -26,7 +26,7 @@ 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'
@@ -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
 
@@ -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
 
@@ -85,8 +86,9 @@ module Hanami
85
86
 
86
87
  def run_handler(message)
87
88
  middleware.invoke(message) { handler.call(message) }
89
+ message.ack!
88
90
  rescue StandardError => e
89
- run_error_handlers(e, message)
91
+ run_error_handlers(e, message.message_id.to_s)
90
92
  message.nack! if CloudPubsub.config.auto_retry.enabled
91
93
  raise
92
94
  end
@@ -132,16 +134,25 @@ module Hanami
132
134
  end
133
135
 
134
136
  def apply_retry_options(sub)
135
- return {} unless CloudPubsub.config.auto_retry.enabled
137
+ retry_policy = build_retry_policy
138
+ attempts = CloudPubsub.config.auto_retry.max_attempts
136
139
 
137
- 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(
138
153
  minimum_backoff: CloudPubsub.config.auto_retry.minimum_backoff,
139
154
  maximum_backoff: CloudPubsub.config.auto_retry.maximum_backoff
140
155
  )
141
- sub.dead_letter_topic = dead_letter_topic
142
- sub.dead_letter_max_delivery_attempts = CloudPubsub.config.auto_retry.max_attempts
143
-
144
- sub
145
156
  end
146
157
  end
147
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.1'
6
+ VERSION = '3.0.6'
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.1
4
+ version: 3.0.6
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-29 00:00:00.000000000 Z
11
+ date: 2020-12-22 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
@@ -223,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
223
  - !ruby/object:Gem::Version
224
224
  version: '0'
225
225
  requirements: []
226
- rubygems_version: 3.1.2
226
+ rubygems_version: 3.0.3
227
227
  signing_key:
228
228
  specification_version: 4
229
229
  summary: Google Cloud Pub/Sub adapter for the hanami-events gem