Module: Bones::RPC::Failover::Retry

Extended by:
Retry
Included in:
Retry
Defined in:
lib/bones/rpc/failover/retry.rb

Overview

Retry is for the case when we get exceptions around the connection, and want to make another attempt to try and resolve the issue.

Since:

  • 2.0.0

Instance Method Summary collapse

Instance Method Details

#execute(exception, node) ⇒ Object

Executes the failover strategy. In the case of retyr, we disconnect and reconnect, then try the operation one more time.

Examples:

Execute the retry strategy.

Bones::RPC::Failover::Retry.execute(exception, node)

Parameters:

  • exception (Exception)

    The raised exception.

  • node (Node)

    The node the exception got raised on.

Returns:

  • (Object)

    The result of the block yield.

Raises:

Since:

  • 2.0.0


27
28
29
30
31
32
33
34
35
# File 'lib/bones/rpc/failover/retry.rb', line 27

def execute(exception, node)
  node.disconnect
  begin
    yield if block_given?
  rescue Exception => e
    node.down
    raise(e)
  end
end