Class: Google::Cloud::Spanner::Database::Job Deprecated

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/spanner/database/job.rb,
lib/google/cloud/spanner/database/job/list.rb

Overview

Deprecated.

Use the long-running operation returned by

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 #update.

Client#create_database instead.

Examples:

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

See Also:

Defined Under Namespace

Classes: List

Instance Method Summary collapse

Instance Method Details

#databaseGoogle::Cloud::Spanner::Database?

The database that is the object of the operation.

Examples:

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

Returns:



95
96
97
98
99
100
101
# File 'lib/google/cloud/spanner/database/job.rb', line 95

def database
  return nil unless done?
  return nil unless @grpc.grpc_op.result == :response
  return nil unless @grpc.results.instance_of? \
    Admin::Database::V1::Database
  Database.from_grpc @grpc.results, service
end

#done?boolean

Checks if the processing of the database operation is complete.

Examples:

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

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

job.done? #=> false

Returns:

  • (boolean)

    true when complete, false otherwise.



118
119
120
# File 'lib/google/cloud/spanner/database/job.rb', line 118

def done?
  @grpc.done?
end

#errorGoogle::Cloud::Spanner::Status?

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

Examples:

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

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

job.error? # true

error = job.error

Returns:



160
161
162
163
# File 'lib/google/cloud/spanner/database/job.rb', line 160

def error
  return nil unless error?
  Google::Cloud::Spanner::Status.from_grpc @grpc.error
end

#error?boolean

Checks if the processing of the database operation has errored.

Examples:

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

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

job.error? #=> false

Returns:

  • (boolean)

    true when errored, false otherwise.



137
138
139
# File 'lib/google/cloud/spanner/database/job.rb', line 137

def error?
  @grpc.error?
end

#reload!Google::Cloud::Spanner::Database::Job Also known as: refresh!

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

Examples:

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

Returns:



184
185
186
187
# File 'lib/google/cloud/spanner/database/job.rb', line 184

def reload!
  @grpc.reload!
  self
end

#wait_until_done!Object

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

Examples:

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


206
207
208
# File 'lib/google/cloud/spanner/database/job.rb', line 206

def wait_until_done!
  @grpc.wait_until_done!
end