Module: Google::Cloud

Defined in:
lib/google-cloud-pubsub.rb,
lib/google/cloud/pubsub.rb,
lib/google/cloud/pubsub/topic.rb,
lib/google/cloud/pubsub/errors.rb,
lib/google/cloud/pubsub/policy.rb,
lib/google/cloud/pubsub/schema.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/snapshot.rb,
lib/google/cloud/pubsub/subscriber.rb,
lib/google/cloud/pubsub/topic/list.rb,
lib/google/cloud/pubsub/credentials.rb,
lib/google/cloud/pubsub/schema/list.rb,
lib/google/cloud/pubsub/retry_policy.rb,
lib/google/cloud/pubsub/subscription.rb,
lib/google/cloud/pubsub/snapshot/list.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/received_message.rb,
lib/google/cloud/pubsub/subscriber/stream.rb,
lib/google/cloud/pubsub/subscription/list.rb,
lib/google/cloud/pubsub/acknowledge_result.rb,
lib/google/cloud/pubsub/subscriber/inventory.rb,
lib/google/cloud/pubsub/subscriber/sequencer.rb,
lib/google/cloud/pubsub/async_publisher/batch.rb,
lib/google/cloud/pubsub/subscription/push_config.rb,
lib/google/cloud/pubsub/subscriber/enumerator_queue.rb,
lib/google/cloud/pubsub/subscriber/timed_unary_buffer.rb

Defined Under Namespace

Modules: PubSub

Lifecycle collapse

Pubsub =

Legacy veneer namespace

PubSub

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.pubsub(project_id = nil, credentials = nil, scope: nil, timeout: 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.

Examples:

require "google/cloud"

pubsub = Google::Cloud.pubsub

topic = pubsub.topic "my-topic"
topic.publish "task completed"

Parameters:

  • project_id (String) (defaults to: nil)

    Project identifier for the Pub/Sub service you are connecting to. If not present, the default project for the credentials is used.

  • credentials (String, Hash, Google::Auth::Credentials) (defaults to: nil)

    The path to the keyfile as a String, the contents of the keyfile as a Hash, or a Google::Auth::Credentials object. (See Google::Cloud::PubSub::Credentials)

  • scope (String, Array<String>) (defaults to: nil)

    The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. See Using OAuth 2.0 to Access Google APIs.

    The default scope is:

    • https://www.googleapis.com/auth/pubsub
  • timeout (Numeric) (defaults to: nil)

    Default timeout to use in requests. Optional.

Returns:



102
103
104
105
106
107
108
# File 'lib/google-cloud-pubsub.rb', line 102

def self.pubsub project_id = nil,
                credentials = nil,
                scope: nil,
                timeout: nil
  require "google/cloud/pubsub"
  Google::Cloud::PubSub.new project_id: project_id, credentials: credentials, scope: scope, timeout: timeout
end

Instance Method Details

#pubsub(scope: nil, timeout: 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.

Examples:

require "google/cloud"

gcloud = Google::Cloud.new
pubsub = gcloud.pubsub
topic = pubsub.topic "my-topic"
topic.publish "task completed"

The default scope can be overridden with the scope option:

require "google/cloud"

gcloud  = Google::Cloud.new
platform_scope = "https://www.googleapis.com/auth/cloud-platform"
pubsub = gcloud.pubsub scope: platform_scope

Parameters:

  • scope (String, Array<String>) (defaults to: nil)

    The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. See Using OAuth 2.0 to Access Google APIs.

    The default scope is:

    • https://www.googleapis.com/auth/pubsub
  • timeout (Numeric) (defaults to: nil)

    Default timeout to use in requests. Optional.

Returns:



63
64
65
66
# File 'lib/google-cloud-pubsub.rb', line 63

def pubsub scope: nil, timeout: nil
  timeout ||= @timeout
  Google::Cloud.pubsub @project, @keyfile, scope: scope, timeout: timeout
end