hanami-events-cloud_pubsub 2.6.0 → 2.8.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: 753a636d5e7a7f4e76eb1865278d0979ad5d338c0c5283f7b22c11a491a42f92
4
- data.tar.gz: 43ba31f43a4b5255d10c4682e9859d14d9f79c9d4036786bd947bf1faa77d042
3
+ metadata.gz: 2a3ea2081b048c0f982067adab81ac696590eb058e3e315f3d4821197c603ea2
4
+ data.tar.gz: 922b58010d619854190bcc4bc03e4b27faa74aeac6f26667b72df11e11c55da0
5
5
  SHA512:
6
- metadata.gz: d1ae226d26f497f50c447784421861e45d99b59624149cecc224d4f6ae9bf2e74f54c9438cfb2ed33c55ab938f4d12913200025d1c40a4b0518d8305ea089762
7
- data.tar.gz: a1a1b64ca8dc346484a699a78508e92b9057ee14d599f1097bf9b84defee04e4af35c59aa039ad30659894d0395d890c490725e4989744a39c936525362fbfd2
6
+ metadata.gz: 6e3ed35de8c4a023db2542603ffeb64bb17c6ceb0bbe024a88baf35b183235673515c426ef7cbf6358f5337f892b77033d4a57818dd197458d41814fafa51398
7
+ data.tar.gz: '079ceb5a54129228eacb1c0a9b8331a34322806e00edefc625b9b557caab58f56c21bc7d6e511f7c2e4a1dc45337a8b298845f40b72aed4e72a8ec7cb50cfdfb'
@@ -1 +1 @@
1
- ruby 2.6.6
1
+ ruby 2.7.1
@@ -9,8 +9,9 @@ env:
9
9
  - CC_TEST_REPORTER_ID=7ab310950456b913cd7e947f6671e3e9c16822f33bd8c572dadcc14593fe4fb5
10
10
  - COVERAGE=true
11
11
  rvm:
12
- - 2.4
12
+ - 2.5
13
13
  - 2.6
14
+ - 2.7
14
15
  before_install:
15
16
  - gem install bundler -v 1.16.1
16
17
  before_script:
@@ -8,9 +8,9 @@ GIT
8
8
  PATH
9
9
  remote: .
10
10
  specs:
11
- hanami-events-cloud_pubsub (2.6.0)
11
+ hanami-events-cloud_pubsub (2.8.0)
12
12
  dry-configurable (>= 0.8)
13
- google-cloud-pubsub (>= 0.38.1, < 1.4)
13
+ google-cloud-pubsub (>= 0.38.1, < 1.7)
14
14
  hanami-cli (~> 0.2)
15
15
  hanami-events (~> 0.2.0)
16
16
  rack
@@ -40,10 +40,10 @@ GEM
40
40
  google-cloud-core (1.5.0)
41
41
  google-cloud-env (~> 1.0)
42
42
  google-cloud-errors (~> 1.0)
43
- google-cloud-env (1.3.1)
43
+ google-cloud-env (1.3.2)
44
44
  faraday (>= 0.17.3, < 2.0)
45
- google-cloud-errors (1.0.0)
46
- google-cloud-pubsub (1.3.1)
45
+ google-cloud-errors (1.0.1)
46
+ google-cloud-pubsub (1.6.1)
47
47
  concurrent-ruby (~> 1.1)
48
48
  google-cloud-core (~> 1.2)
49
49
  google-gax (~> 1.8)
@@ -56,7 +56,7 @@ GEM
56
56
  googleauth (~> 0.9)
57
57
  grpc (~> 1.24)
58
58
  rly (~> 0.2.3)
59
- google-protobuf (3.11.4)
59
+ google-protobuf (3.12.2)
60
60
  googleapis-common-protos (1.3.10)
61
61
  google-protobuf (~> 3.11)
62
62
  googleapis-common-protos-types (>= 1.0.5, < 2.0)
@@ -97,7 +97,7 @@ GEM
97
97
  pry (0.13.1)
98
98
  coderay (~> 1.1)
99
99
  method_source (~> 1.0)
100
- public_suffix (4.0.4)
100
+ public_suffix (4.0.5)
101
101
  rack (2.2.2)
102
102
  rainbow (3.0.0)
103
103
  rake (13.0.1)
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.require_paths = ['lib']
24
24
 
25
25
  spec.add_dependency 'dry-configurable', '>= 0.8'
26
- spec.add_dependency 'google-cloud-pubsub', '>= 0.38.1', '< 1.4'
26
+ spec.add_dependency 'google-cloud-pubsub', '>= 0.38.1', '< 1.7'
27
27
  spec.add_dependency 'hanami-cli', '~> 0.2'
28
28
  spec.add_dependency 'hanami-events', '~> 0.2.0'
29
29
  spec.add_dependency 'rack'
@@ -28,13 +28,13 @@ module Hanami
28
28
  #
29
29
  # @param event [Symbol, String] the event name
30
30
  # @param payload [Hash] the event data
31
- def broadcast(name, payload)
31
+ def broadcast(name, payload, **message_opts)
32
32
  event_name = namespaced(name)
33
33
  topic = topic_for event_name
34
34
  payload = serializer.serialize(payload)
35
35
  attributes = { id: SecureRandom.uuid, event_name: event_name }
36
36
 
37
- topic.publish_async(payload, attributes) do |result|
37
+ topic.publish_async(payload, **attributes, **message_opts) do |result|
38
38
  logger.info "Published event #{result.inspect}"
39
39
  end
40
40
  end
@@ -6,7 +6,6 @@ require 'hanami/events/cloud_pubsub/version'
6
6
  require 'hanami/events/cloud_pubsub/middleware/stack'
7
7
  require 'hanami/events/cloud_pubsub/middleware/logging'
8
8
  require 'hanami/events/cloud_pubsub/middleware/auto_retry'
9
- require 'hanami/events/cloud_pubsub/middleware/prometheus'
10
9
  require 'hanami/events/cloud_pubsub/runner'
11
10
  require 'hanami/events/cloud_pubsub/errors'
12
11
  require 'google/cloud/pubsub'
@@ -63,7 +62,13 @@ module Hanami
63
62
  Middleware::AutoRetry.new
64
63
  )
65
64
 
66
- middleware_stack.prepend(Middleware::Prometheus) if defined?(::Prometheus::Client)
65
+ begin
66
+ require 'prometheus/client'
67
+ require 'hanami/events/cloud_pubsub/middleware/prometheus'
68
+ middleware_stack.prepend(Middleware::Prometheus.new)
69
+ rescue LoadError
70
+ # ok
71
+ end
67
72
 
68
73
  setting :middleware, middleware_stack
69
74
 
@@ -14,10 +14,10 @@ module Hanami
14
14
  @max_attempts = max_attempts
15
15
  end
16
16
 
17
- def call(message, args = {})
17
+ def call(message, **args)
18
18
  succeeded = false
19
19
  failed = false
20
- yield(args)
20
+ yield(**args)
21
21
  succeeded = true
22
22
  rescue StandardError => e
23
23
  failed = true
@@ -10,9 +10,9 @@ module Hanami
10
10
  @logger = logger
11
11
  end
12
12
 
13
- def call(msg, opts = {})
13
+ def call(msg, **opts)
14
14
  started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
15
- yield(opts)
15
+ yield(**opts)
16
16
  ensure
17
17
  ended_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
18
18
  seconds = ended_at - started_at
@@ -12,18 +12,28 @@ module Hanami
12
12
  require 'prometheus/client'
13
13
  prometheus = ::Prometheus::Client.registry
14
14
  @events_counter = prometheus.counter(
15
- :pubsub_events,
15
+ :received_pubsub_events,
16
16
  docstring: 'A counter of received pubsub events',
17
- labels: %i[event_name subscription]
17
+ labels: %i[event_name subscription status]
18
18
  )
19
19
  end
20
20
 
21
- def call(msg, opts = {})
22
- yield(opts)
21
+ def call(msg, **opts)
22
+ status = :running
23
+
24
+ begin
25
+ ret = yield(**opts)
26
+ status = :succeeded
27
+ ret
28
+ rescue StandardError
29
+ status = :failed
30
+ raise
31
+ end
23
32
  ensure
24
33
  sub = msg.subscription.subscriber.subscription_name
25
34
  event_name = msg.attributes['event_name']
26
- events_counter.increment(labels: { event_name: event_name, subscription: sub })
35
+ labels = { event_name: event_name, subscription: sub, status: status }
36
+ events_counter.increment(labels: labels)
27
37
  end
28
38
  end
29
39
  end
@@ -3,7 +3,7 @@
3
3
  module Hanami
4
4
  module Events
5
5
  module CloudPubsub
6
- VERSION = '2.6.0'
6
+ VERSION = '2.8.0'
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: 2.6.0
4
+ version: 2.8.0
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-04-27 00:00:00.000000000 Z
11
+ date: 2020-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: 0.38.1
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
- version: '1.4'
36
+ version: '1.7'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 0.38.1
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
- version: '1.4'
46
+ version: '1.7'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: hanami-cli
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -208,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
208
  - !ruby/object:Gem::Version
209
209
  version: '0'
210
210
  requirements: []
211
- rubygems_version: 3.0.3
211
+ rubygems_version: 3.1.2
212
212
  signing_key:
213
213
  specification_version: 4
214
214
  summary: Google Cloud Pub/Sub adapter for the hanami-events gem