Class: Fluent::GcloudPubSub::Publisher
- Inherits:
-
Object
- Object
- Fluent::GcloudPubSub::Publisher
- Defined in:
- lib/fluent/plugin/gcloud_pubsub/client.rb
Instance Method Summary collapse
-
#initialize(project, key, topic, autocreate_topic) ⇒ Publisher
constructor
A new instance of Publisher.
- #publish(messages) ⇒ Object
Constructor Details
#initialize(project, key, topic, autocreate_topic) ⇒ Publisher
Returns a new instance of Publisher.
8 9 10 11 12 13 |
# File 'lib/fluent/plugin/gcloud_pubsub/client.rb', line 8 def initialize(project, key, topic, autocreate_topic) pubsub = (Google::Cloud.new project, key).pubsub @client = pubsub.topic topic, autocreate: autocreate_topic raise Fluent::GcloudPubSub::Error.new "topic:#{topic} does not exist." if @client.nil? end |
Instance Method Details
#publish(messages) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/fluent/plugin/gcloud_pubsub/client.rb', line 15 def publish() @client.publish do |batch| .each do |m| batch.publish m end end end |