Reference documentation and code samples for the Cloud Spanner API class Google::Cloud::Spanner::Instance::Job.
Job
A resource representing the long-running, asynchronous processing of an instance create or update operation. The job can be refreshed to retrieve the instance object once the operation has been completed.
See {Project#create_instance} and {Instance#update}.
{Google::Cloud::Spanner::Admin::Instance#instance_admin Client#create_instance} instead.
Inherits
- Object
Example
require "google/cloud/spanner" spanner = Google::Cloud::Spanner.new job = spanner.create_instance "my-new-instance", name: "My New Instance", config: "regional-us-central1", nodes: 5, labels: { production: :env } job.done? #=> false job.reload! # API call job.done? #=> true if job.error? status = job.error else instance = job.instance end
Methods
#done?
def done?() -> boolean
Checks if the processing of the instance operation is complete.
-
(boolean) —
true
when complete,false
otherwise.
require "google/cloud/spanner" spanner = Google::Cloud::Spanner.new job = spanner.create_instance "my-new-instance", name: "My New Instance", config: "regional-us-central1", nodes: 5, labels: { production: :env } job.done? #=> false
#error
def error() -> Google::Cloud::Spanner::Status, nil
The status if the operation associated with this job produced an error.
-
(Google::Cloud::Spanner::Status, nil) — A status object with
the status code and message, or
nil
if no error occurred.
require "google/cloud/spanner" spanner = Google::Cloud::Spanner.new job = spanner.create_instance "my-new-instance", name: "My New Instance", config: "regional-us-central1", nodes: 5, labels: { production: :env } job.error? # true error = job.error
#error?
def error?() -> boolean
Checks if the processing of the instance operation has errored.
-
(boolean) —
true
when errored,false
otherwise.
require "google/cloud/spanner" spanner = Google::Cloud::Spanner.new job = spanner.create_instance "my-new-instance", name: "My New Instance", config: "regional-us-central1", nodes: 5, labels: { production: :env } job.error? #=> false
#instance
def instance() -> Google::Cloud::Spanner::Instance, nil
The instance that is the object of the operation.
-
(Google::Cloud::Spanner::Instance, nil) — The instance, or
nil
if the operation is not complete.
require "google/cloud/spanner" spanner = Google::Cloud::Spanner.new job = spanner.create_instance "my-new-instance", name: "My New Instance", config: "regional-us-central1", nodes: 5, labels: { production: :env } job.done? #=> false job.reload! job.done? #=> true instance = job.instance
#refresh!
def refresh!() -> Google::Cloud::Spanner::Instance::Job
Reloads the job with current data from the long-running, asynchronous processing of an instance operation.
- (Google::Cloud::Spanner::Instance::Job) — The same job instance.
require "google/cloud/spanner" spanner = Google::Cloud::Spanner.new job = spanner.create_instance "my-new-instance", name: "My New Instance", config: "regional-us-central1", nodes: 5, labels: { production: :env } job.done? #=> false job.reload! # API call job.done? #=> true
#reload!
def reload!() -> Google::Cloud::Spanner::Instance::Job
Reloads the job with current data from the long-running, asynchronous processing of an instance operation.
- (Google::Cloud::Spanner::Instance::Job) — The same job instance.
require "google/cloud/spanner" spanner = Google::Cloud::Spanner.new job = spanner.create_instance "my-new-instance", name: "My New Instance", config: "regional-us-central1", nodes: 5, labels: { production: :env } 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.
require "google/cloud/spanner" spanner = Google::Cloud::Spanner.new job = spanner.create_instance "my-new-instance", name: "My New Instance", config: "regional-us-central1", nodes: 5, labels: { production: :env } job.done? #=> false job.wait_until_done! job.done? #=> true