Module: Google::Cloud::PubSub
- Defined in:
- lib/google/cloud/pubsub.rb,
lib/google/cloud/pubsub/errors.rb,
lib/google/cloud/pubsub/convert.rb,
lib/google/cloud/pubsub/message.rb,
lib/google/cloud/pubsub/project.rb,
lib/google/cloud/pubsub/service.rb,
lib/google/cloud/pubsub/version.rb,
lib/google/cloud/pubsub/publisher.rb,
lib/google/cloud/pubsub/subscriber.rb,
lib/google/cloud/pubsub/credentials.rb,
lib/google/cloud/pubsub/admin_clients.rb,
lib/google/cloud/pubsub/publish_result.rb,
lib/google/cloud/pubsub/async_publisher.rb,
lib/google/cloud/pubsub/batch_publisher.rb,
lib/google/cloud/pubsub/flow_controller.rb,
lib/google/cloud/pubsub/internal_logger.rb,
lib/google/cloud/pubsub/message_listener.rb,
lib/google/cloud/pubsub/received_message.rb,
lib/google/cloud/pubsub/acknowledge_result.rb,
lib/google/cloud/pubsub/async_publisher/batch.rb,
lib/google/cloud/pubsub/message_listener/stream.rb,
lib/google/cloud/pubsub/message_listener/inventory.rb,
lib/google/cloud/pubsub/message_listener/sequencer.rb,
lib/google/cloud/pubsub/message_listener/enumerator_queue.rb,
lib/google/cloud/pubsub/message_listener/timed_unary_buffer.rb
Overview
Google Cloud Pub/Sub
Google Cloud Pub/Sub is designed to provide reliable, many-to-many, asynchronous messaging between applications. Publisher applications can send messages to a "topic" and other applications can subscribe to that topic to receive the messages. By decoupling senders and receivers, Google Cloud Pub/Sub allows developers to communicate between independently written applications.
Defined Under Namespace
Modules: SubscriptionAdmin, TopicAdmin Classes: AcknowledgeResult, AsyncPublisher, AsyncPublisherStopped, BatchPublisher, Credentials, FlowControlLimitError, Message, MessageListener, OrderedMessageDeliveryError, OrderedMessagesDisabled, OrderingKeyError, Project, PublishResult, Publisher, ReceivedMessage, Subscriber
Constant Summary collapse
- DEFAULT_COMPRESS =
false- DEFAULT_COMPRESSION_BYTES_THRESHOLD =
240- VERSION =
"3.3.0".freeze
Class Method Summary collapse
-
.configure {|Google::Cloud.configure.pubsub| ... } ⇒ Google::Cloud::Config
Configure the Google Cloud PubSub library.
-
.new(project_id: nil, credentials: nil, scope: nil, timeout: nil, universe_domain: nil, endpoint: nil, emulator_host: nil, logger: nil) ⇒ Google::Cloud::PubSub::Project
Creates a new object for connecting to the Pub/Sub service.
Class Method Details
.configure {|Google::Cloud.configure.pubsub| ... } ⇒ Google::Cloud::Config
Configure the Google Cloud PubSub library.
The following PubSub configuration parameters are supported:
project_id- (String) Identifier for a PubSub project.credentials- (String, Hash, Google::Auth::Credentials) The path to the keyfile as a String, the contents of the keyfile as a Hash, or a Google::Auth::Credentials object. (See Credentials)scope- (String, Array) The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. quota_project- (String) The project ID for a project that can be used by client libraries for quota and billing purposes.timeout- (Numeric) Default timeout to use in requests.endpoint- (String) Override of the endpoint host name, ornilto use the default endpoint.emulator_host- (String) Host name of the emulator. Defaults toENV["PUBSUB_EMULATOR_HOST"]on_error- (Proc) A Proc to be run when an error is encountered on a background thread. The Proc must take the error object as the single argument. (See Google::Cloud::PubSub::MessageListener#on_error.)
159 160 161 162 163 |
# File 'lib/google/cloud/pubsub.rb', line 159 def self.configure yield Google::Cloud.configure.pubsub if block_given? Google::Cloud.configure.pubsub end |
.new(project_id: nil, credentials: nil, scope: nil, timeout: nil, universe_domain: nil, endpoint: nil, emulator_host: nil, logger: nil) ⇒ Google::Cloud::PubSub::Project
Creates a new object for connecting to the Pub/Sub service. Each call creates a new connection.
For more information on connecting to Google Cloud see the Authentication Guide.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/google/cloud/pubsub.rb', line 95 def self.new project_id: nil, credentials: nil, scope: nil, timeout: nil, universe_domain: nil, endpoint: nil, emulator_host: nil, logger: nil project_id ||= default_project_id scope ||= configure.scope timeout ||= configure.timeout endpoint ||= configure.endpoint universe_domain ||= configure.universe_domain emulator_host ||= configure.emulator_host logger ||= configure.logger if emulator_host credentials = :this_channel_is_insecure endpoint = emulator_host else credentials ||= default_credentials scope: scope unless credentials.is_a? Google::Auth::Credentials credentials = PubSub::Credentials.new credentials, scope: scope end end project_id ||= credentials.project_id if credentials.respond_to? :project_id project_id = project_id.to_s # Always cast to a string raise ArgumentError, "project_id is missing" if project_id.empty? logger = Google::Cloud::PubSub::InternalLogger.new logger service = PubSub::Service.new project_id, credentials, host: endpoint, timeout: timeout, universe_domain: universe_domain, logger: logger PubSub::Project.new service end |