Class: Google::Cloud::Spanner::Database::Job
- Inherits:
-
Object
- Object
- Google::Cloud::Spanner::Database::Job
- Defined in:
- lib/google/cloud/spanner/database/job.rb
Overview
# 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.
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#database ⇒ Google::Cloud::Spanner::Database?
The database that is the object of the operation.
-
#done? ⇒ boolean
Checks if the processing of the database operation is complete.
-
#error ⇒ Google::Cloud::Spanner::Status?
The status if the operation associated with this job produced an error.
-
#error? ⇒ boolean
Checks if the processing of the database operation has errored.
-
#initialize ⇒ Job
constructor
A new instance of Job.
-
#reload! ⇒ Google::Cloud::Spanner::Database::Job
(also: #refresh!)
Reloads the job with current data from the long-running, asynchronous processing of a database operation.
-
#wait_until_done! ⇒ Object
Reloads the job until the operation is complete.
Constructor Details
#initialize ⇒ Job
Returns a new instance of Job.
57 58 59 60 |
# File 'lib/google/cloud/spanner/database/job.rb', line 57 def initialize @grpc = nil @service = nil end |
Instance Attribute Details
#grpc ⇒ Object
49 50 51 |
# File 'lib/google/cloud/spanner/database/job.rb', line 49 def grpc @grpc end |
#service ⇒ Object
53 54 55 |
# File 'lib/google/cloud/spanner/database/job.rb', line 53 def service @service end |
Class Method Details
.from_grpc(grpc, service) ⇒ Object
196 197 198 199 200 201 |
# File 'lib/google/cloud/spanner/database/job.rb', line 196 def self.from_grpc grpc, service new.tap do |job| job.instance_variable_set :@grpc, grpc job.instance_variable_set :@service, service end end |
Instance Method Details
#database ⇒ Google::Cloud::Spanner::Database?
The database that is the object of the operation.
81 82 83 84 85 |
# File 'lib/google/cloud/spanner/database/job.rb', line 81 def database return nil unless done? return nil unless @grpc.grpc_op.result == :response Database.from_grpc @grpc.results, service end |
#done? ⇒ boolean
Checks if the processing of the database operation is complete.
102 103 104 |
# File 'lib/google/cloud/spanner/database/job.rb', line 102 def done? @grpc.done? end |
#error ⇒ Google::Cloud::Spanner::Status?
The status if the operation associated with this job produced an error.
144 145 146 147 |
# File 'lib/google/cloud/spanner/database/job.rb', line 144 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.
121 122 123 |
# File 'lib/google/cloud/spanner/database/job.rb', line 121 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.
168 169 170 171 |
# File 'lib/google/cloud/spanner/database/job.rb', line 168 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.
190 191 192 |
# File 'lib/google/cloud/spanner/database/job.rb', line 190 def wait_until_done! @grpc.wait_until_done! end |