Class: Chronos::Ports::TransportResult

Inherits:
Object
  • Object
show all
Defined in:
lib/chronos/ports/transport.rb

Overview

Result returned by transport adapters instead of raising into the application.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, options = {}) ⇒ TransportResult

Returns a new instance of TransportResult.



13
14
15
16
17
18
19
20
# File 'lib/chronos/ports/transport.rb', line 13

def initialize(status, options = {})
  @status = status
  @status_code = options[:status_code]
  @retry_after = options[:retry_after]
  @error = options[:error]
  @remote_configuration = options[:remote_configuration]
  freeze
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



11
12
13
# File 'lib/chronos/ports/transport.rb', line 11

def error
  @error
end

#remote_configurationObject (readonly)

Returns the value of attribute remote_configuration.



11
12
13
# File 'lib/chronos/ports/transport.rb', line 11

def remote_configuration
  @remote_configuration
end

#retry_afterObject (readonly)

Returns the value of attribute retry_after.



11
12
13
# File 'lib/chronos/ports/transport.rb', line 11

def retry_after
  @retry_after
end

#statusObject (readonly)

Returns the value of attribute status.



11
12
13
# File 'lib/chronos/ports/transport.rb', line 11

def status
  @status
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



11
12
13
# File 'lib/chronos/ports/transport.rb', line 11

def status_code
  @status_code
end

Instance Method Details

#retryable?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/chronos/ports/transport.rb', line 26

def retryable?
  [:request_timeout, :rate_limited, :server_error, :network_error].include?(status)
end

#success?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/chronos/ports/transport.rb', line 22

def success?
  status == :success
end