Class: Cloudenvoy::PubSubClient
- Inherits:
-
Object
- Object
- Cloudenvoy::PubSubClient
- Defined in:
- lib/cloudenvoy/pub_sub_client.rb
Overview
Interface to publishing backend (GCP, emulator or memory backend)
Class Method Summary collapse
-
.backend ⇒ Module<Cloudenvoy::Backend::MemoryPubSub, Cloudenvoy::Backend::GoogleCloudTask>
Return the backend to use for sending messages.
-
.publish(topic, payload, attrs = {}) ⇒ Cloudenvoy::Message
Publish a message to a topic.
-
.publish_all(topic, msg_args) ⇒ Array<Cloudenvoy::Message>
Publish multiple messages to a topic.
-
.upsert_subscription(topic, name, opts = {}) ⇒ Cloudenvoy::Subscription
Create or update a subscription for a specific topic.
-
.upsert_topic(topic) ⇒ Cloudenvoy::Topic
Create or update a topic.
Class Method Details
.backend ⇒ Module<Cloudenvoy::Backend::MemoryPubSub, Cloudenvoy::Backend::GoogleCloudTask>
Return the backend to use for sending messages.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/cloudenvoy/pub_sub_client.rb', line 11 def self.backend # Re-evaluate backend every time if testing mode enabled @backend = nil if defined?(Cloudenvoy::Testing) @backend ||= begin if defined?(Cloudenvoy::Testing) && Cloudenvoy::Testing.in_memory? require 'cloudenvoy/backend/memory_pub_sub' Backend::MemoryPubSub else require 'cloudenvoy/backend/google_pub_sub' Backend::GooglePubSub end end end |
.publish(topic, payload, attrs = {}) ⇒ Cloudenvoy::Message
Publish a message to a topic.
35 36 37 |
# File 'lib/cloudenvoy/pub_sub_client.rb', line 35 def self.publish(topic, payload, attrs = {}) backend.publish(topic, payload, attrs) end |
.publish_all(topic, msg_args) ⇒ Array<Cloudenvoy::Message>
Publish multiple messages to a topic.
47 48 49 |
# File 'lib/cloudenvoy/pub_sub_client.rb', line 47 def self.publish_all(topic, msg_args) backend.publish_all(topic, msg_args) end |
.upsert_subscription(topic, name, opts = {}) ⇒ Cloudenvoy::Subscription
Create or update a subscription for a specific topic.
73 74 75 |
# File 'lib/cloudenvoy/pub_sub_client.rb', line 73 def self.upsert_subscription(topic, name, opts = {}) backend.upsert_subscription(topic, name, opts) end |
.upsert_topic(topic) ⇒ Cloudenvoy::Topic
Create or update a topic.
84 85 86 |
# File 'lib/cloudenvoy/pub_sub_client.rb', line 84 def self.upsert_topic(topic) backend.upsert_topic(topic) end |