hanami-events-cloud_pubsub 1.2.0 → 1.2.1

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
- SHA1:
3
- metadata.gz: 71ff4098b0a82d321cb62937858972c0bfa583ef
4
- data.tar.gz: bdd7a5a9f2bfcfd6a19f26566ea58102a6a3c226
2
+ SHA256:
3
+ metadata.gz: 49ddb33f0919dfdcd8b9691f5a7c9738c1f8450e7b526b5fed74d7f50a6b6e02
4
+ data.tar.gz: d91a005b6c22deaa3bd86a63b22a381459342afc4d8567a9ea78f8bed28a209c
5
5
  SHA512:
6
- metadata.gz: dc55657ad7d0cc2e803d24a52f31fb958d71647309840c5317a96c255480f4cdc51c6fc57eb47749434e21a383bfd48050af68bc85f4e6d34b38cb7c57ac4847
7
- data.tar.gz: d9d25d3d10f1eab932e7b845209c08a14f0dce2284d26832a7cf19a9686749e98d9582e18b07ca7cb3bb37d646c25468c0f00ddb7ec567f3f5fe1ed95d6efc88
6
+ metadata.gz: df6a87b7373f4d6e08ed53668575512a11523c359897684f0e30463fa376e2a0307dc8cbf335b6631abb88ac5a2087a71ff8b013e1e48bf66c42ccd3a4eb7348
7
+ data.tar.gz: d326e6ab180bac789fe8e894c45a4ae522d9ecbd4f741a130967d21eab0b282cb13032dde2e4e27183b9d538082d6c815ec0f249764cd63d1a7eb35b6d9be160
@@ -2,6 +2,8 @@
2
2
  inherit_from: .rubocop_todo.yml
3
3
 
4
4
  AllCops:
5
+ Exclude:
6
+ - bin/*
5
7
  TargetRubyVersion: 2.3
6
8
 
7
9
  Metrics/BlockLength:
data/Gemfile CHANGED
@@ -8,7 +8,7 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
8
8
  gemspec
9
9
 
10
10
  group :test do
11
- gem 'hanami-events', github: 'ianks/events', branch: 'args-to-subscribe'
11
+ gem 'hanami-events', github: 'hanami/events'
12
12
  gem 'pry'
13
13
  gem 'rubocop', '~> 0.54.0'
14
14
  gem 'simplecov', require: false
@@ -1,7 +1,6 @@
1
1
  GIT
2
- remote: https://github.com/ianks/events
3
- revision: 29539d68cae73faa638b5b4691fd87ec2b34a447
4
- branch: args-to-subscribe
2
+ remote: https://github.com/hanami/events
3
+ revision: e2b076d3ba7c1dfd78daa48500abd9c538a5e9c6
5
4
  specs:
6
5
  hanami-events (0.1.0)
7
6
  dry-container (~> 0.6)
@@ -9,7 +8,7 @@ GIT
9
8
  PATH
10
9
  remote: .
11
10
  specs:
12
- hanami-events-cloud_pubsub (1.2.0)
11
+ hanami-events-cloud_pubsub (1.2.1)
13
12
  dry-configurable (~> 0.7.0)
14
13
  google-cloud-pubsub (~> 0.33.0)
15
14
  hanami-cli (~> 0.2.0)
@@ -41,7 +40,7 @@ GEM
41
40
  google-cloud-core (~> 1.2)
42
41
  google-gax (~> 1.3)
43
42
  grpc-google-iam-v1 (~> 0.6.9)
44
- google-gax (1.3.0)
43
+ google-gax (1.4.0)
45
44
  google-protobuf (~> 3.2)
46
45
  googleapis-common-protos (>= 1.3.5, < 2.0)
47
46
  googleauth (~> 0.6.2)
@@ -112,7 +111,7 @@ GEM
112
111
  ruby-progressbar (~> 1.7)
113
112
  unicode-display_width (~> 1.0, >= 1.0.1)
114
113
  ruby-progressbar (1.10.0)
115
- signet (0.9.2)
114
+ signet (0.10.0)
116
115
  addressable (~> 2.3)
117
116
  faraday (~> 0.9)
118
117
  jwt (>= 1.5, < 3.0)
@@ -139,4 +138,4 @@ DEPENDENCIES
139
138
  simplecov
140
139
 
141
140
  BUNDLED WITH
142
- 1.16.1
141
+ 1.16.5
data/README.md CHANGED
@@ -49,6 +49,13 @@ Hanami.events.subscribe('user.deleted', id: 'my-subscriber-id') do |payload|
49
49
  end
50
50
  ```
51
51
 
52
+ Additional options will be passed to `Google::Cloud::Pubsub::Subscription#listen`:
53
+ ```ruby
54
+ Hanami.events.subscribe('foo', id: 'bar', deadline: 30) do |payload|
55
+ sleep 29 # message will finish before deadline
56
+ end
57
+ ```
58
+
52
59
  2. Responding to events is done in a different process via the CLI.
53
60
 
54
61
  First, create a config file:
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
@@ -39,14 +39,16 @@ module Hanami
39
39
  # Subscribes block for selected event
40
40
  #
41
41
  # @param event_name [Symbol, String] the event name
42
+ # @param id [String] A unique identifier for the subscriber
43
+ # @param subscriber_opts [String] Additional options for the subscriber
42
44
  # @param block [Block] to execute when event is broadcasted
43
- def subscribe(event_name, id:, &block)
45
+ def subscribe(event_name, id:, **subscriber_opts, &block)
44
46
  logger.debug("Subscribed listener \"#{id}\" for event \"#{event_name}\"")
45
47
 
46
48
  @subscribers << Subscriber.new(event_name, block, logger)
47
49
  topic = topic_for event_name
48
50
 
49
- register_listener(event_name, topic, id)
51
+ register_listener(event_name, topic, id, subscriber_opts)
50
52
  end
51
53
 
52
54
  def flush_messages
@@ -58,13 +60,14 @@ module Hanami
58
60
 
59
61
  attr_reader :logger
60
62
 
61
- def register_listener(event_name, topic, subscriber_id)
63
+ def register_listener(event_name, topic, subscriber_id, subscriber_opts)
62
64
  listener = ::Hanami::Events::CloudPubsub::Listener.new(
63
65
  subscriber_id: subscriber_id,
64
66
  event_name: event_name,
65
67
  handler: method(:call_subscribers),
66
68
  logger: logger,
67
- topic: topic
69
+ topic: topic,
70
+ subscriber_opts: subscriber_opts
68
71
  )
69
72
 
70
73
  @listeners << listener
@@ -18,20 +18,23 @@ module Hanami
18
18
  :subscriber_opts,
19
19
  :middleware
20
20
 
21
+ # rubocop:disable Metrics/ParameterLists
21
22
  def initialize(topic:,
22
23
  logger:,
23
24
  handler:,
24
25
  event_name:,
25
26
  subscriber_id:,
27
+ subscriber_opts: {},
26
28
  middleware: CloudPubsub.config.middleware)
27
29
  @topic = topic
28
30
  @logger = logger
29
31
  @handler = handler
30
32
  @event_name = event_name
31
33
  @subscriber_id = subscriber_id
32
- @subscriber_opts = CloudPubsub.config.subscriber.to_h
34
+ @subscriber_opts = CloudPubsub.config.subscriber.to_h.merge(subscriber_opts)
33
35
  @middleware = middleware
34
36
  end
37
+ # rubocop:enable Metrics/ParameterLists
35
38
 
36
39
  def register
37
40
  subscription = subscription_for(subscriber_id)
@@ -3,7 +3,7 @@
3
3
  module Hanami
4
4
  module Events
5
5
  module CloudPubsub
6
- VERSION = '1.2.0'
6
+ VERSION = '1.2.1'
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: 1.2.0
4
+ version: 1.2.1
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: 2018-09-21 00:00:00.000000000 Z
11
+ date: 2018-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable
@@ -128,6 +128,7 @@ files:
128
128
  - README.md
129
129
  - Rakefile
130
130
  - bin/console
131
+ - bin/rspec
131
132
  - bin/setup
132
133
  - docker-compose.yml
133
134
  - examples/client.rb
@@ -170,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
171
  version: '0'
171
172
  requirements: []
172
173
  rubyforge_project:
173
- rubygems_version: 2.6.14
174
+ rubygems_version: 2.7.7
174
175
  signing_key:
175
176
  specification_version: 4
176
177
  summary: Google Cloud Pub/Sub adapter for the hanami-events gem