Invocation

public class Invocation<A, B>

Invocation entity. A context function receives an Invocation object as its parameter. The Invocation object allows you to notify the circuit breaker of success or failure, provided that a timeout has not already been triggered.

  • Arguments for circuit command.

    Declaration

    Swift

    public let commandArgs: A
  • Arguments for circuit fallback.

    Declaration

    Swift

    public let fallbackArgs: B
  • Invocation initializer.

    Declaration

    Swift

    public init(startTime: Date, breaker: CircuitBreaker<A, B>, commandArgs: A, fallbackArgs: B)

    Parameters

    startTime

    The startTime for Invocation.

    breaker

    CircuitBreaker instance.

    commandArgs

    Arguments of type A for the command context.

    fallbackArgs

    Arguments of type B for the circuit fallback.

  • Marks invocation as having timed out if and only if the execution of the invocation has not completed yet. In such case, true is returned; otherwise, false.

    Usage Example:

    result = invocation.notifyTimedOut()
    

    Declaration

    Swift

    public func notifyTimedOut() -> Bool
  • Notifies the circuit breaker of success if a timeout has not already been triggered.

    Usage Example:

    invocation.notifySuccess()
    

    Declaration

    Swift

    public func notifySuccess()
  • Notifies the circuit breaker of failure if a timeout has not already been triggered.

    Usage Example:

    The example below notifies the circuit breaker of a predefined encodingURLError.

    invocation.notifyFailure(error: .encodingURLError)
    

    Declaration

    Swift

    public func notifyFailure(error: BreakerError)

    Parameters

    error

    The corresponding error msg.