pubsub_tie 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pubsub_tie.rb +4 -0
- data/lib/pubsub_tie/publisher.rb +16 -1
- data/lib/pubsub_tie/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cc8c5620bfda35e60f358ea6b2cdee4e800c027d1ca9c405dbce3ce861be5fe
|
4
|
+
data.tar.gz: f8d6f1c5b6bb267e64dca4fedb13cf48aa2a7cc7cef10899c4711809fa129471
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22f689074bb1dde17cfd75de1a40fdc9a6efe53cd1f6456a76a6b30ea1726a85ba4c526b3c2552904764fd2b4788a177e32847c2fd4d89e0ffae48f1ede5caff
|
7
|
+
data.tar.gz: 700eedab10a24a766b278a677c4cd582a70e151fdcfd510784811be9191478abad8a12e68d91bf7c532a0222892ad39ddfbbee1fbb6f26c810f2098907188426
|
data/lib/pubsub_tie.rb
CHANGED
@@ -39,6 +39,10 @@ module PubSubTie
|
|
39
39
|
def publish(topic, data, resource: nil)
|
40
40
|
Publisher.publish(topic, data, resource)
|
41
41
|
end
|
42
|
+
|
43
|
+
def batch(topic, data, resource: nil)
|
44
|
+
Publisher.batch(topic, data, resource)
|
45
|
+
end
|
42
46
|
end
|
43
47
|
|
44
48
|
require 'pubsub_tie/railtie' if defined? Rails::Railtie
|
data/lib/pubsub_tie/publisher.rb
CHANGED
@@ -24,11 +24,26 @@ module PubSubTie
|
|
24
24
|
publish_time: Time.now.utc) do |result|
|
25
25
|
unless result.succeeded?
|
26
26
|
Rails.logger.error(
|
27
|
-
"Failed to publish #{data} to #{
|
27
|
+
"Failed to publish #{data} to #{topic_sym} on #{resource} due to #{result.error}")
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
def batch(topic_sym, messages, resource)
|
33
|
+
topic = @pubsub.
|
34
|
+
topic(Events.name topic_sym)
|
35
|
+
messages.each do |data|
|
36
|
+
topic.publish_async(message(validate_data(topic_sym, data), resource),
|
37
|
+
publish_time: Time.now.utc) do |result|
|
38
|
+
unless result.succeeded?
|
39
|
+
Rails.logger.error(
|
40
|
+
"Failed to publish #{data} to #{topic_sym} on #{data} due to #{result.error}")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
topic.async_publisher.stop.wait!
|
45
|
+
end
|
46
|
+
|
32
47
|
private
|
33
48
|
def message(data, resource)
|
34
49
|
# TODO: embed resource in message
|
data/lib/pubsub_tie/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pubsub_tie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pablo Calderon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-cloud-pubsub
|
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '0'
|
99
99
|
requirements: []
|
100
|
-
rubygems_version: 3.0.
|
100
|
+
rubygems_version: 3.0.6
|
101
101
|
signing_key:
|
102
102
|
specification_version: 4
|
103
103
|
summary: Hook for Google PubSub for publication of events enforcing autoimposed rules
|