Class: Stenotype::Adapters::GoogleCloud
- Defined in:
- lib/stenotype/adapters/google_cloud.rb
Overview
An adapter implementing method #publish to send data to Google Cloud PubSub
Instance Method Summary collapse
-
#auto_initialize! ⇒ Object
If not called both client and topic are lazy initialized on first call (if not passed to #initialize).
-
#flush! ⇒ Object
Flushes the topic's async queue.
- #publish(event_data, **additional_attrs) ⇒ Object
Methods inherited from Base
Constructor Details
This class inherits a constructor from Stenotype::Adapters::Base
Instance Method Details
#auto_initialize! ⇒ Object
If not called both client and topic are lazy initialized on first call (if not passed to #initialize). #auto_initialize! is going to explicitly initialize both client and topic.
74 75 76 77 |
# File 'lib/stenotype/adapters/google_cloud.rb', line 74 def auto_initialize! client topic end |
#flush! ⇒ Object
Flushes the topic's async queue
62 63 64 65 66 67 |
# File 'lib/stenotype/adapters/google_cloud.rb', line 62 def flush! # a publisher might be uninitialized until the first event is published return unless topic.async_publisher topic.async_publisher.stop.wait! end |
#publish(event_data, **additional_attrs) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/stenotype/adapters/google_cloud.rb', line 51 def publish(event_data, **additional_attrs) if config.async publish_async(event_data, **additional_attrs) else publish_sync(event_data, **additional_attrs) end end |