Class: TxghQueue::Supervisor

Inherits:
Object
  • Object
show all
Defined in:
lib/txgh-queue/supervisor.rb

Constant Summary collapse

ERROR_HANDLERS =

ErrorHandlers::StandardErrors should always come last as a catch-all for unexpected errors. All errors handled by this supervisor inherit from StandardError, so putting it too early in the handler list may cause an error to be mis-handled.

[
  ErrorHandlers::ServerResponse,
  ErrorHandlers::Github,
  ErrorHandlers::Gitlab,
  ErrorHandlers::Transifex,
  ErrorHandlers::TxghErrors,
  ErrorHandlers::StandardErrors,
  ErrorHandlers::NetworkErrors
]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Supervisor

Returns a new instance of Supervisor.



29
30
31
# File 'lib/txgh-queue/supervisor.rb', line 29

def initialize(&block)
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



27
28
29
# File 'lib/txgh-queue/supervisor.rb', line 27

def block
  @block
end

Class Method Details

.supervise(&block) ⇒ Object



22
23
24
# File 'lib/txgh-queue/supervisor.rb', line 22

def supervise(&block)
  new(&block).execute
end

Instance Method Details

#executeObject



33
34
35
36
37
38
39
40
41
# File 'lib/txgh-queue/supervisor.rb', line 33

def execute
  response = block.call
rescue StandardError => e
  status = status_for_error(e)
  Result.new(status, e)
else
  status = status_for_response(response)
  Result.new(status, response)
end