Cloud Spanner API - Class Google::Cloud::Spanner::Database::Job (v2.15.0)

Reference documentation and code samples for the Cloud Spanner API class Google::Cloud::Spanner::Database::Job.

Job

A resource representing the long-running, asynchronous processing of a database create or update operation. The job can be refreshed to retrieve the database object once the operation has been completed.

See {Project#create_database} and {Database#update}.

{Google::Cloud::Spanner::Admin::Database#database_admin Client#create_database} instead.

Inherits

  • Object

Example

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

job = spanner.create_database "my-instance",
                              "my-new-database"

job.done? #=> false
job.reload! # API call
job.done? #=> true

if job.error?
  status = job.error
else
  database = job.database
end

Methods

#database

def database() -> Google::Cloud::Spanner::Database, nil

The database that is the object of the operation.

Returns
Example
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

job = spanner.create_database "my-instance",
                              "my-new-database"

job.done? #=> false
job.reload!
job.done? #=> true
database = job.database

#done?

def done?() -> boolean

Checks if the processing of the database operation is complete.

Returns
  • (boolean) — true when complete, false otherwise.
Example
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

job = spanner.create_database "my-instance",
                              "my-new-database"

job.done? #=> false

#error

def error() -> Google::Cloud::Spanner::Status, nil

The status if the operation associated with this job produced an error.

Returns
Example
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

job = spanner.create_database "my-instance",
                              "my-new-database"

job.error? # true

error = job.error

#error?

def error?() -> boolean

Checks if the processing of the database operation has errored.

Returns
  • (boolean) — true when errored, false otherwise.
Example
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

job = spanner.create_database "my-instance",
                              "my-new-database"

job.error? #=> false

#refresh!

def refresh!() -> Google::Cloud::Spanner::Database::Job
Alias Of: #reload!

Reloads the job with current data from the long-running, asynchronous processing of a database operation.

Returns
Example
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

job = spanner.create_database "my-instance",
                              "my-new-database"

job.done? #=> false
job.reload! # API call
job.done? #=> true

#reload!

def reload!() -> Google::Cloud::Spanner::Database::Job
Aliases

Reloads the job with current data from the long-running, asynchronous processing of a database operation.

Returns
Example
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

job = spanner.create_database "my-instance",
                              "my-new-database"

job.done? #=> false
job.reload! # API call
job.done? #=> true

#wait_until_done!

def wait_until_done!()

Reloads the job until the operation is complete. The delay between reloads will incrementally increase.

Example
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

job = spanner.create_database "my-instance",
                              "my-new-database"

job.done? #=> false
job.wait_until_done!
job.done? #=> true