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 +5 -5
- data/Gemfile.lock +2 -2
- data/lib/hanami/events/cloud_pubsub.rb +1 -0
- data/lib/hanami/events/cloud_pubsub/cli.rb +6 -0
- data/lib/hanami/events/cloud_pubsub/listener.rb +3 -1
- data/lib/hanami/events/cloud_pubsub/runner.rb +4 -1
- data/lib/hanami/events/cloud_pubsub/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3e32a098f1de2fd09c4bc5c6426de01c1b1f2901
|
4
|
+
data.tar.gz: ee797299d3b807a971ba55c26c56c2df39d42a71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
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)
|
@@ -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.
|
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 :
|
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
|
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.
|
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-
|
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.
|
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
|