class PubsubClient
Constants
- ConfigurationError
- CredentialsError
- Error
- InvalidSubscriptionError
- InvalidTopicError
- VERSION
Attributes
publisher_factory[R]
stubbed[R]
subscriber_factory[R]
Public Instance Methods
publish(message, topic, attributes = {}, &block)
click to toggle source
# File lib/pubsub_client.rb, line 32 def publish(message, topic, attributes = {}, &block) ensure_credentials! @publisher_factory ||= PublisherFactory.new @publisher_factory.build(topic).publish(message, attributes, &block) end
stub!()
click to toggle source
# File lib/pubsub_client.rb, line 16 def stub! raise ConfigurationError, 'PubsubClient is already configured' if @publisher_factory || @subscriber_factory @publisher_factory = NullPublisherFactory.new @subscriber_factory = NullSubscriberFactory.new @stubbed = true end
subscriber(subscription)
click to toggle source
@param subscription [String] - The name of the subscription to subscribe to.
# File lib/pubsub_client.rb, line 25 def subscriber(subscription) ensure_credentials! @subscriber_factory ||= SubscriberFactory.new @subscriber_factory.build(subscription) end
Private Instance Methods
ensure_credentials!()
click to toggle source
# File lib/pubsub_client.rb, line 43 def ensure_credentials! return if defined?(stubbed) && stubbed unless ENV['GOOGLE_APPLICATION_CREDENTIALS'] raise CredentialsError, 'GOOGLE_APPLICATION_CREDENTIALS must be set' end end