Class: BigShift::CloudStorageTransfer

Inherits:
Object
  • Object
show all
Defined in:
lib/bigshift/cloud_storage_transfer.rb

Instance Method Summary collapse

Constructor Details

#initialize(storage_transfer_service, project_id, aws_credentials, options = {}) ⇒ CloudStorageTransfer

Returns a new instance of CloudStorageTransfer.



3
4
5
6
7
8
9
10
# File 'lib/bigshift/cloud_storage_transfer.rb', line 3

def initialize(storage_transfer_service, project_id, aws_credentials, options={})
  @storage_transfer_service = storage_transfer_service
  @project_id = project_id
  @aws_credentials = aws_credentials
  @clock = options[:clock] || Time
  @thread = options[:thread] || Kernel
  @logger = options[:logger] || NullLogger::INSTANCE
end

Instance Method Details

#copy_to_cloud_storage(s3_bucket, s3_path_prefix, cloud_storage_bucket, options = {}) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/bigshift/cloud_storage_transfer.rb', line 12

def copy_to_cloud_storage(s3_bucket, s3_path_prefix, cloud_storage_bucket, options={})
  poll_interval = options[:poll_interval] || DEFAULT_POLL_INTERVAL
  transfer_job = create_transfer_job(s3_bucket, s3_path_prefix, cloud_storage_bucket, options[:description], options[:allow_overwrite])
  transfer_job = @storage_transfer_service.create_transfer_job(transfer_job)
  @logger.info(sprintf('Transferring objects from s3://%s/%s to gs://%s/%s', s3_bucket, s3_path_prefix, cloud_storage_bucket, s3_path_prefix))
  await_completion(transfer_job, poll_interval)
  nil
end