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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a07811f6de7eee6628bff537126ed2186da058002ec43d2f5789278869a2b739
4
- data.tar.gz: 5bfe2ac42674e2720d3aaf4cf5262befc892eb62d8959ffed827a90a49aa33a8
3
+ metadata.gz: 8cc8c5620bfda35e60f358ea6b2cdee4e800c027d1ca9c405dbce3ce861be5fe
4
+ data.tar.gz: f8d6f1c5b6bb267e64dca4fedb13cf48aa2a7cc7cef10899c4711809fa129471
5
5
  SHA512:
6
- metadata.gz: e6eb7e15aa40bb9c19ceee94430269d256c5c0e36a4e02d4fe8a0387ea39c99590890e818ff5fc7b15d8fd4453770c9a9ab5e2ca144e992b7e37cd4e60d3cc93
7
- data.tar.gz: 164bdc7080b020257cf852618dcd75540102767cd18bf84d1dd20510d1c626bf4b0f103f20255072b41af972641bff2aa33ef7af804513b8d18eabbc1dffce55
6
+ metadata.gz: 22f689074bb1dde17cfd75de1a40fdc9a6efe53cd1f6456a76a6b30ea1726a85ba4c526b3c2552904764fd2b4788a177e32847c2fd4d89e0ffae48f1ede5caff
7
+ data.tar.gz: 700eedab10a24a766b278a677c4cd582a70e151fdcfd510784811be9191478abad8a12e68d91bf7c532a0222892ad39ddfbbee1fbb6f26c810f2098907188426
@@ -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
@@ -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 #{topic_name} on #{resource} due to #{result.error}")
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
@@ -1,3 +1,3 @@
1
1
  module PubSubTie
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
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-05-22 00:00:00.000000000 Z
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.3
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