Class: Google::Cloud::Spanner::Backup::Job Deprecated

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

Overview

Deprecated.

Use the long-running operation returned by

Job

A resource representing the long-running, asynchronous processing of backup creation. The job can be refreshed to retrieve the backup object once the operation has been completed.

See Database#create_backup

Client#create_backup instead.

Examples:

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

database = spanner.database "my-instance", "my-database"
expire_time = Time.now + 36000
job = database.create_backup "my-backup", expire_time

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

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

See Also:

Defined Under Namespace

Classes: List

Instance Method Summary collapse

Instance Method Details

#backupBackup?

The backup is the object of the operation.

Examples:

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

database = spanner.database "my-instance", "my-database"
expire_time = Time.now + 36000
job = database.create_backup "my-backup", expire_time

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

Returns:

  • (Backup, nil)

    The backup, or nil if the operation is not complete.



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

def backup
  return nil unless done?
  return nil unless @grpc.grpc_op.result == :response
  Backup.from_grpc @grpc.results, service
end

#cancelObject

Cancel the backup job.

Examples:

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

database = spanner.database "my-instance", "my-database"
expire_time = Time.now + 36000
job = database.create_backup "my-backup", expire_time

job.done? #=> false
job.cancel


230
231
232
# File 'lib/google/cloud/spanner/backup/job.rb', line 230

def cancel
  @grpc.cancel
end

#cancel_timeTime?

The operation canceled time.

Returns:

  • (Time, nil)


264
265
266
267
# File 'lib/google/cloud/spanner/backup/job.rb', line 264

def cancel_time
  return nil unless @grpc..cancel_time
  Convert.timestamp_to_time @grpc..cancel_time
end

#done?boolean

Checks if the processing of the backup operation is complete.

Examples:

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

database = spanner.database "my-instance", "my-database"
expire_time = Time.now + 36000
job = database.create_backup "my-backup", expire_time

job.done? #=> false

Returns:

  • (boolean)

    true when complete, false otherwise.



119
120
121
# File 'lib/google/cloud/spanner/backup/job.rb', line 119

def done?
  @grpc.done?
end

#end_timeTime?

The operation end time.

Returns:

  • (Time, nil)


255
256
257
258
# File 'lib/google/cloud/spanner/backup/job.rb', line 255

def end_time
  return nil unless @grpc..progress.end_time
  Convert.timestamp_to_time @grpc..progress.end_time
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

database = spanner.database "my-instance", "my-database"
expire_time = Time.now + 36000
job = database.create_backup "my-backup", expire_time

job.error? # true

error = job.error

Returns:



163
164
165
166
# File 'lib/google/cloud/spanner/backup/job.rb', line 163

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

#error?boolean

Checks if the processing of the backup operation has errored.

Examples:

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

database = spanner.database "my-instance", "my-database"
expire_time = Time.now + 36000
job = database.create_backup "my-backup", expire_time

job.error? #=> false

Returns:

  • (boolean)

    true when errored, false otherwise.



139
140
141
# File 'lib/google/cloud/spanner/backup/job.rb', line 139

def error?
  @grpc.error?
end

#progress_percentInteger

The operation progress in percentage.

Returns:

  • (Integer)


238
239
240
# File 'lib/google/cloud/spanner/backup/job.rb', line 238

def progress_percent
  @grpc..progress.progress_percent
end

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

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

Examples:

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

database = spanner.database "my-instance", "my-database"
expire_time = Time.now + 36000
job = database.create_backup "my-backup", expire_time

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

Returns:



188
189
190
191
# File 'lib/google/cloud/spanner/backup/job.rb', line 188

def reload!
  @grpc.reload!
  self
end

#start_timeTime?

The operation start time.

Returns:

  • (Time, nil)


246
247
248
249
# File 'lib/google/cloud/spanner/backup/job.rb', line 246

def start_time
  return nil unless @grpc..progress.start_time
  Convert.timestamp_to_time @grpc..progress.start_time
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

database = spanner.database "my-instance", "my-database"
expire_time = Time.now + 36000
job = database.create_backup "my-backup", expire_time

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


211
212
213
# File 'lib/google/cloud/spanner/backup/job.rb', line 211

def wait_until_done!
  @grpc.wait_until_done!
end