Class: PubsubClient::Publisher

Inherits:
Object
  • Object
show all
Defined in:
lib/pubsub_client/publisher.rb

Instance Method Summary collapse

Constructor Details

#initialize(topic) ⇒ Publisher

Returns a new instance of Publisher.

Parameters:

  • topic (Google::Cloud::PubSub::Topic)


8
9
10
# File 'lib/pubsub_client/publisher.rb', line 8

def initialize(topic)
  @topic = topic
end

Instance Method Details

#flushObject



16
17
18
19
# File 'lib/pubsub_client/publisher.rb', line 16

def flush
  return unless topic.async_publisher
  topic.async_publisher.stop.wait!
end

#publish(message, attributes = {}, &block) ⇒ Object



12
13
14
# File 'lib/pubsub_client/publisher.rb', line 12

def publish(message, attributes = {}, &block)
  topic.publish_async(message, attributes, &block)
end