hanami-events-cloud_pubsub 2.1.4 → 2.2.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: e51fcb2486cdeca9c675d1a37e4c70f21ba9cad09fc3a148294cb03f1a2570ec
4
- data.tar.gz: cdfad2c9b22abf3c4c80349b977c7f966e0a1c40faf955f4553ab06cbf999eb1
3
+ metadata.gz: d33982e2387371df286bc6db08827c261359e4b51dac99cc4d9311716dac9624
4
+ data.tar.gz: bb59baae9c834328876f7ddba328ff2cfe5af8fc2b0aa1922cea05167da8df6b
5
5
  SHA512:
6
- metadata.gz: 820f3a4bed9594d8ce3b287232d59d1a4d2b96334b6b4ce4ce5ee0693db56536902e89773321f7486319a86a1f39f077ec1410c4a5cd5930004366325724feb0
7
- data.tar.gz: 6349ab7adf08c16a7847f51e94278ca771a40ebf1ebbb567b1b78c53e8dabea06143e5a37b07f119533b7d91fa17c331e4693dd4ffe356f69f4f97b4f42c3311
6
+ metadata.gz: 50f3e78a8a54a75fcb844d67e8a56de59caffba97d45738e23f87db528cd872eef7b47fd628b45243f2844fdcb0ecaf0458eff8a6eca1ed9aac57eb20ddaabdb
7
+ data.tar.gz: e9320cb4a20633db80fae907da755aaca18775e81552dd2fce0cf61b914d980252e2385414ba4b7bc5f2b568ec9147360eea5f7069635fdef4c57b235d271d1a
data/Gemfile CHANGED
@@ -7,9 +7,7 @@ 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
- group :test do
11
- gem 'hanami-events', github: 'hanami/events'
12
- gem 'pry'
13
- gem 'rubocop', '~> 0.54.0'
14
- gem 'simplecov', require: false
15
- end
10
+ gem 'hanami-events', github: 'hanami/events'
11
+ gem 'pry'
12
+ gem 'rubocop'
13
+ gem 'simplecov', require: false
data/Gemfile.lock CHANGED
@@ -8,9 +8,9 @@ GIT
8
8
  PATH
9
9
  remote: .
10
10
  specs:
11
- hanami-events-cloud_pubsub (2.1.4)
11
+ hanami-events-cloud_pubsub (2.2.0)
12
12
  dry-configurable (~> 0.8.0)
13
- google-cloud-pubsub (~> 0.34.0)
13
+ google-cloud-pubsub (>= 0.34, < 0.38)
14
14
  hanami-cli (~> 0.2)
15
15
  hanami-events (~> 0.2.0)
16
16
 
@@ -21,75 +21,76 @@ GEM
21
21
  public_suffix (>= 2.0.2, < 4.0)
22
22
  ast (2.4.0)
23
23
  coderay (1.1.2)
24
- concurrent-ruby (1.1.4)
24
+ concurrent-ruby (1.1.5)
25
25
  diff-lcs (1.3)
26
- docile (1.3.1)
27
- dry-configurable (0.8.2)
26
+ docile (1.3.2)
27
+ dry-configurable (0.8.3)
28
28
  concurrent-ruby (~> 1.0)
29
29
  dry-core (~> 0.4, >= 0.4.7)
30
- dry-container (0.7.0)
30
+ dry-container (0.7.1)
31
31
  concurrent-ruby (~> 1.0)
32
32
  dry-configurable (~> 0.1, >= 0.1.3)
33
- dry-core (0.4.7)
33
+ dry-core (0.4.8)
34
34
  concurrent-ruby (~> 1.0)
35
35
  faraday (0.15.4)
36
36
  multipart-post (>= 1.2, < 3)
37
37
  google-cloud-core (1.3.0)
38
38
  google-cloud-env (~> 1.0)
39
- google-cloud-env (1.0.5)
39
+ google-cloud-env (1.2.0)
40
40
  faraday (~> 0.11)
41
- google-cloud-pubsub (0.34.1)
42
- concurrent-ruby (~> 1.0)
41
+ google-cloud-pubsub (0.37.0)
42
+ concurrent-ruby (~> 1.1)
43
43
  google-cloud-core (~> 1.2)
44
44
  google-gax (~> 1.3)
45
+ googleapis-common-protos (>= 1.3.9, < 2.0)
45
46
  grpc-google-iam-v1 (~> 0.6.9)
46
- google-gax (1.5.0)
47
+ google-gax (1.7.0)
47
48
  google-protobuf (~> 3.2)
48
49
  googleapis-common-protos (>= 1.3.5, < 2.0)
49
50
  googleauth (>= 0.6.2, < 0.10.0)
50
51
  grpc (>= 1.7.2, < 2.0)
51
52
  rly (~> 0.2.3)
52
- google-protobuf (3.7.0)
53
- googleapis-common-protos (1.3.8)
53
+ google-protobuf (3.8.0-x86_64-linux)
54
+ googleapis-common-protos (1.3.9)
54
55
  google-protobuf (~> 3.0)
55
56
  googleapis-common-protos-types (~> 1.0)
56
57
  grpc (~> 1.0)
57
- googleapis-common-protos-types (1.0.3)
58
+ googleapis-common-protos-types (1.0.4)
58
59
  google-protobuf (~> 3.0)
59
- googleauth (0.8.0)
60
+ googleauth (0.8.1)
60
61
  faraday (~> 0.12)
61
62
  jwt (>= 1.4, < 3.0)
62
63
  memoist (~> 0.16)
63
64
  multi_json (~> 1.11)
64
65
  os (>= 0.9, < 2.0)
65
66
  signet (~> 0.7)
66
- grpc (1.19.0)
67
- google-protobuf (~> 3.1)
68
- googleapis-common-protos-types (~> 1.0.0)
67
+ grpc (1.21.0-x86_64-linux)
68
+ google-protobuf (~> 3.7)
69
+ googleapis-common-protos-types (~> 1.0)
69
70
  grpc-google-iam-v1 (0.6.9)
70
71
  googleapis-common-protos (>= 1.3.1, < 2.0)
71
72
  grpc (~> 1.0)
72
73
  hanami-cli (0.3.1)
73
74
  concurrent-ruby (~> 1.0)
74
75
  hanami-utils (~> 1.3)
75
- hanami-utils (1.3.1)
76
+ hanami-utils (1.3.2)
76
77
  concurrent-ruby (~> 1.0)
77
78
  transproc (~> 1.0)
79
+ jaro_winkler (1.5.3)
78
80
  json (2.2.0)
79
- jwt (2.1.0)
81
+ jwt (2.2.1)
80
82
  memoist (0.16.0)
81
83
  method_source (0.9.2)
82
84
  multi_json (1.13.1)
83
- multipart-post (2.0.0)
84
- os (1.0.0)
85
- parallel (1.14.0)
86
- parser (2.6.0.0)
85
+ multipart-post (2.1.1)
86
+ os (1.0.1)
87
+ parallel (1.17.0)
88
+ parser (2.6.3.0)
87
89
  ast (~> 2.4.0)
88
- powerpack (0.1.2)
89
90
  pry (0.12.2)
90
91
  coderay (~> 1.1.0)
91
92
  method_source (~> 0.9.0)
92
- public_suffix (3.0.3)
93
+ public_suffix (3.1.1)
93
94
  rainbow (3.0.0)
94
95
  rake (12.3.2)
95
96
  rly (0.2.3)
@@ -97,35 +98,35 @@ GEM
97
98
  rspec-core (~> 3.8.0)
98
99
  rspec-expectations (~> 3.8.0)
99
100
  rspec-mocks (~> 3.8.0)
100
- rspec-core (3.8.0)
101
+ rspec-core (3.8.2)
101
102
  rspec-support (~> 3.8.0)
102
- rspec-expectations (3.8.2)
103
+ rspec-expectations (3.8.4)
103
104
  diff-lcs (>= 1.2.0, < 2.0)
104
105
  rspec-support (~> 3.8.0)
105
- rspec-mocks (3.8.0)
106
+ rspec-mocks (3.8.1)
106
107
  diff-lcs (>= 1.2.0, < 2.0)
107
108
  rspec-support (~> 3.8.0)
108
- rspec-support (3.8.0)
109
- rubocop (0.54.0)
109
+ rspec-support (3.8.2)
110
+ rubocop (0.72.0)
111
+ jaro_winkler (~> 1.5.1)
110
112
  parallel (~> 1.10)
111
- parser (>= 2.5)
112
- powerpack (~> 0.1)
113
+ parser (>= 2.6)
113
114
  rainbow (>= 2.2.2, < 4.0)
114
115
  ruby-progressbar (~> 1.7)
115
- unicode-display_width (~> 1.0, >= 1.0.1)
116
- ruby-progressbar (1.10.0)
116
+ unicode-display_width (>= 1.4.0, < 1.7)
117
+ ruby-progressbar (1.10.1)
117
118
  signet (0.11.0)
118
119
  addressable (~> 2.3)
119
120
  faraday (~> 0.9)
120
121
  jwt (>= 1.5, < 3.0)
121
122
  multi_json (~> 1.10)
122
- simplecov (0.16.1)
123
+ simplecov (0.17.0)
123
124
  docile (~> 1.1)
124
125
  json (>= 1.8, < 3)
125
126
  simplecov-html (~> 0.10.0)
126
127
  simplecov-html (0.10.2)
127
128
  transproc (1.0.3)
128
- unicode-display_width (1.5.0)
129
+ unicode-display_width (1.6.0)
129
130
 
130
131
  PLATFORMS
131
132
  ruby
@@ -137,7 +138,7 @@ DEPENDENCIES
137
138
  pry
138
139
  rake (~> 12.3)
139
140
  rspec (~> 3.0)
140
- rubocop (~> 0.54.0)
141
+ rubocop
141
142
  simplecov
142
143
 
143
144
  BUNDLED WITH
@@ -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.0'
26
- spec.add_dependency 'google-cloud-pubsub', '~> 0.34.0'
26
+ spec.add_dependency 'google-cloud-pubsub', '>= 0.34', '< 0.38'
27
27
  spec.add_dependency 'hanami-cli', '~> 0.2'
28
28
  spec.add_dependency 'hanami-events', '~> 0.2.0'
29
29
 
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'hanami/events/cloud_pubsub/listener'
4
+ require 'hanami/events/cloud_pubsub/subscriber'
5
+ require 'hanami/events/cloud_pubsub/errors'
4
6
 
5
7
  module Hanami
6
8
  module Events
@@ -49,7 +51,8 @@ module Hanami
49
51
 
50
52
  logger.debug("Subscribed listener \"#{id}\" for event \"#{event_name}\"")
51
53
 
52
- @subscribers << Subscriber.new(event_name, block, logger)
54
+ sub = Hanami::Events::CloudPubsub::Subscriber.new(event_name, block, logger)
55
+ @subscribers << sub
53
56
  topic = topic_for event_name
54
57
 
55
58
  register_listener(event_name, topic, namespaced_id, subscriber_opts)
@@ -84,7 +87,7 @@ module Hanami
84
87
  event_name = message.attributes['event_name']
85
88
 
86
89
  @subscribers.each do |subscriber|
87
- subscriber.call(event_name, payload)
90
+ subscriber.call(event_name, payload, message)
88
91
  end
89
92
  end
90
93
 
@@ -97,7 +100,7 @@ module Hanami
97
100
  @topic_registry[name.to_s] ||= begin
98
101
  @pubsub.find_topic(name) ||
99
102
  (Hanami::Events::CloudPubsub.auto_create_topics && @pubsub.create_topic(name)) ||
100
- raise(CloudPubsub::Errors::TopicNotFoundError, "no topic named: #{name}")
103
+ raise(::Hanami::Events::CloudPubsub::Errors::TopicNotFoundError, "no topic named: #{name}")
101
104
  end
102
105
  end
103
106
  # rubocop:enable Metrics/LineLength
@@ -83,8 +83,8 @@ module Hanami
83
83
 
84
84
  def run_handler(message)
85
85
  middleware.invoke(message) { handler.call(message) }
86
- rescue StandardError => err
87
- run_error_handlers(err, message)
86
+ rescue StandardError => e
87
+ run_error_handlers(e, message)
88
88
  raise
89
89
  end
90
90
 
@@ -19,9 +19,9 @@ module Hanami
19
19
  failed = false
20
20
  yield(args)
21
21
  succeeded = true
22
- rescue StandardError => err
22
+ rescue StandardError => e
23
23
  failed = true
24
- raise err
24
+ raise e
25
25
  ensure
26
26
  ack_or_reject(message, succeeded, failed, args)
27
27
  end
@@ -7,10 +7,10 @@ module Hanami
7
7
  module SafeErrorHandler
8
8
  def self.call(handler, err, message)
9
9
  handler.call(err, message)
10
- rescue StandardError => ex
10
+ rescue StandardError => e
11
11
  CloudPubsub.logger.error '!!! ERROR HANDLER THREW AN ERROR !!!'
12
- CloudPubsub.logger.error ex
13
- CloudPubsub.logger.error ex.backtrace.join("\n") unless ex.backtrace.nil?
12
+ CloudPubsub.logger.error e
13
+ CloudPubsub.logger.error e.backtrace.join("\n") unless e.backtrace.nil?
14
14
  end
15
15
  end
16
16
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hanami
4
+ module Events
5
+ module CloudPubsub
6
+ # Subscriber class for calling subscriber blocks, with extra support for
7
+ # passing the raw message.
8
+ #
9
+ # @since 0.1.0
10
+ #
11
+ # @api private
12
+ class Subscriber < ::Hanami::Events::Subscriber
13
+ def initialize(event_name, handler, logger = nil, data_struct_class = nil)
14
+ super
15
+ @handler = handler
16
+ end
17
+
18
+ def call(event_name, payload, message)
19
+ return unless @pattern_matcher.match?(event_name)
20
+
21
+ data_object = @data_struct_class ? @data_struct_class.new(payload) : payload
22
+
23
+ if @handler.arity == 2
24
+ @handler.call(data_object, message)
25
+ else
26
+ @handler.call(data_object)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -3,7 +3,7 @@
3
3
  module Hanami
4
4
  module Events
5
5
  module CloudPubsub
6
- VERSION = '2.1.4'
6
+ VERSION = '2.2.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.1.4
4
+ version: 2.2.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: 2019-03-20 00:00:00.000000000 Z
11
+ date: 2019-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable
@@ -28,16 +28,22 @@ dependencies:
28
28
  name: google-cloud-pubsub
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0.34'
34
+ - - "<"
32
35
  - !ruby/object:Gem::Version
33
- version: 0.34.0
36
+ version: '0.38'
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0.34'
44
+ - - "<"
39
45
  - !ruby/object:Gem::Version
40
- version: 0.34.0
46
+ version: '0.38'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: hanami-cli
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -149,6 +155,7 @@ files:
149
155
  - lib/hanami/events/cloud_pubsub/register.rb
150
156
  - lib/hanami/events/cloud_pubsub/runner.rb
151
157
  - lib/hanami/events/cloud_pubsub/safe_error_handler.rb
158
+ - lib/hanami/events/cloud_pubsub/subscriber.rb
152
159
  - lib/hanami/events/cloud_pubsub/thread_inspector.rb
153
160
  - lib/hanami/events/cloud_pubsub/version.rb
154
161
  - log/.keep
@@ -172,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
179
  version: '0'
173
180
  requirements: []
174
181
  rubyforge_project:
175
- rubygems_version: 2.7.7
182
+ rubygems_version: 2.7.8
176
183
  signing_key:
177
184
  specification_version: 4
178
185
  summary: Google Cloud Pub/Sub adapter for the hanami-events gem