hanami-events-cloud_pubsub 0.2.0 → 0.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
- SHA256:
3
- metadata.gz: 7ba6ce6fe08440e7ac49969a63b2b6f4e2412c24a3fa45effbf11563f8c6f5cd
4
- data.tar.gz: c072c528e2379cb1a32a1e7aef86858315e3638c856488e4967cdbe62696312f
2
+ SHA1:
3
+ metadata.gz: 3e32a098f1de2fd09c4bc5c6426de01c1b1f2901
4
+ data.tar.gz: ee797299d3b807a971ba55c26c56c2df39d42a71
5
5
  SHA512:
6
- metadata.gz: b76340517e3a21af94fc94deb6a2dd0cf93ca46c86a285e64b7ed516b3501ab355fc22cfae7b9a8ef9085909fc454583ced8ae16e666f8a2cd5200d931cad362
7
- data.tar.gz: acdce37077630472a14d0a2b4c7179a4535e72a5f7c0a890752cc525909d4d91b6ce3d56a705459d57d4bd6ee48571b2c25cfe177e5b819c7219bb1010d2f619
6
+ metadata.gz: 947616cdbd3ca4a37918db0071306f24411c06ebb351b0b5b8364c2b8660c4fab4e4959e10367d45d6e676f2ee2f6169bd86a5d7fdceb6539b085b77273c400b
7
+ data.tar.gz: e47ed44cf294950d6c087443587e5f0b3c05e76f58c9f92aadbc167e728071fa016f4b742858cd680652f1021365a60315d5ebc9745950ad2111f8a7b1444466
data/Gemfile.lock CHANGED
@@ -9,7 +9,7 @@ GIT
9
9
  PATH
10
10
  remote: .
11
11
  specs:
12
- hanami-events-cloud_pubsub (0.2.0)
12
+ hanami-events-cloud_pubsub (0.2.1)
13
13
  dry-configurable
14
14
  google-cloud-pubsub (~> 0.30.2)
15
15
  hanami-cli
@@ -41,7 +41,7 @@ GEM
41
41
  google-cloud-core (~> 1.2)
42
42
  google-gax (~> 1.0)
43
43
  grpc-google-iam-v1 (~> 0.6.9)
44
- google-gax (1.2.0)
44
+ google-gax (1.3.0)
45
45
  google-protobuf (~> 3.2)
46
46
  googleapis-common-protos (>= 1.3.5, < 2.0)
47
47
  googleauth (~> 0.6.2)
@@ -13,6 +13,7 @@ module Hanami
13
13
  module CloudPubsub
14
14
  extend Dry::Configurable
15
15
 
16
+ setting :project_id, reader: true
16
17
  setting :logger, Logger.new(STDOUT), reader: true
17
18
  setting :subscriptions_loader, proc {
18
19
  abort <<~MSG
@@ -23,6 +23,10 @@ module Hanami
23
23
  default: './config/cloudpubsub.rb',
24
24
  desc: 'Config file which is loaded before starting the runner'
25
25
 
26
+ option :project_id,
27
+ type: :string,
28
+ desc: 'Project ID for the project'
29
+
26
30
  def call(opts)
27
31
  setup_env(opts)
28
32
  parse_opts(opts)
@@ -72,6 +76,7 @@ module Hanami
72
76
  end
73
77
 
74
78
  def parse_opts(opts)
79
+ @project_id = opts[:project_id]
75
80
  @emulator = opts[:emulator]
76
81
  @config = opts[:config]
77
82
  end
@@ -80,6 +85,7 @@ module Hanami
80
85
  pubsub_opts = {}
81
86
 
82
87
  pubsub_opts[:project_id] = 'emulator' if @emulator
88
+ pubsub_opts[:project_id] = @project_id if @project_id
83
89
 
84
90
  pubsub = Google::Cloud::Pubsub.new pubsub_opts
85
91
  $events = Hanami::Events.initialize(:cloud_pubsub,
@@ -95,7 +95,9 @@ module Hanami
95
95
  # rubocop:enable Metrics/MethodLength
96
96
 
97
97
  def subscription_for(name)
98
- topic.find_subscription(name) || topic.create_subscription(name)
98
+ topic.create_subscription(name)
99
+ rescue Google::Cloud::AlreadyExistsError
100
+ # OK
99
101
  end
100
102
 
101
103
  def ensure_subscriber!
@@ -7,7 +7,7 @@ module Hanami
7
7
  module CloudPubsub
8
8
  # Responsible for starting and managing the work processes
9
9
  class Runner
10
- attr_reader :events, :logger, :adapter
10
+ attr_reader :logger, :adapter
11
11
 
12
12
  def initialize(adapter:, logger:, sleep_time: 2)
13
13
  @logger = logger
@@ -19,6 +19,7 @@ module Hanami
19
19
  def start(_options = {})
20
20
  logger.info 'Starting CloudPubsub listeners'
21
21
  adapter.listeners.map(&:start)
22
+ self
22
23
  end
23
24
 
24
25
  # Will be called on TSTP
@@ -30,6 +31,7 @@ module Hanami
30
31
  def pause
31
32
  logger.info 'Pausing CloudPubsub runner'
32
33
  adapter.listeners.each(&:stop)
34
+ self
33
35
  end
34
36
 
35
37
  # Will be called on SIGINT, TERM
@@ -43,6 +45,7 @@ module Hanami
43
45
  sleep_for_a_bit
44
46
  adapter.flush_messages
45
47
  adapter.listeners.each(&:wait)
48
+ self
46
49
  end
47
50
 
48
51
  # (optional) Kill all subscribers
@@ -3,7 +3,7 @@
3
3
  module Hanami
4
4
  module Events
5
5
  module CloudPubsub
6
- VERSION = '0.2.0'
6
+ VERSION = '0.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: 0.2.0
4
+ version: 0.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-06-07 00:00:00.000000000 Z
11
+ date: 2018-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  version: '0'
166
166
  requirements: []
167
167
  rubyforge_project:
168
- rubygems_version: 2.7.7
168
+ rubygems_version: 2.6.14
169
169
  signing_key:
170
170
  specification_version: 4
171
171
  summary: Google Cloud Pub/Sub adapter for the hanami-events gem