Class: Aspera::Agent::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/aspera/agent/base.rb

Overview

Base class for transfer agents Transfer agents provide methods:

  • start_transfer : take a transfer spec and start a transfer asynchronously
  • wait_for_transfers_completion : waits for all transfer sessions to finish
  • notify_progress : called back by transfer agent to notify transfer progress
  • self.transfer_status : (optional) re-query a previously started transfer by id

Direct Known Subclasses

Connect, Desktop, Direct, Httpgw, Node, Transferd

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.transfer_status(_transfer_id, _agent_params) ⇒ Hash?

Re-query the status of a transfer that was started asynchronously. Override in agents that support live status queries (desktop, node, connect, transferd).

Parameters:

  • transfer_id (String) —

    opaque id returned by start_transfer

  • agent_params (Hash) —

    connection parameters stored at submission time

Returns:

  • (Hash, nil) —

    status hash with at least 'status' key, or nil if not supported



20
21
22
# File 'lib/aspera/agent/base.rb', line 20

def transfer_status(_transfer_id, _agent_params)
  nil
end

Instance Method Details

#last_job_id ⇒ String?

Return the job_id of the last transfer submitted by this agent. In-process agents (direct, httpgw) override this to expose their internal job id. Remote-daemon agents do not need to override it: TransferAgent generates a UUID itself.

Returns:



40
41
42
# File 'lib/aspera/agent/base.rb', line 40

def last_job_id
  nil
end

#wait_for_completion ⇒ Transfer::Result::Success, Transfer::Result::Error

Wait for all sessions to terminate and return a typed Transfer::Result.



27
28
29
30
31
32
33
34
# File 'lib/aspera/agent/base.rb', line 27

def wait_for_completion
  statuses = wait_for_transfers_completion
  @progress&.reset
  Aspera.assert_type(statuses, Array)
  Aspera.assert(statuses.none? { |i| !i.eql?(:success) && !i.is_a?(StandardError) }) { "bad statuses content: #{statuses}" }
  errors = statuses.reject { |i| i.eql?(:success) }
  return errors.empty? ? Transfer::Result.success : Transfer::Result.error(errors.first)
end