Circuit Breakers

Default Circuit Breaker Strategy

See here for information on the settings used for the circuit breaker strategy.

oci.circuit_breaker.DEFAULT_CIRCUIT_BREAKER_STRATEGY = <oci.circuit_breaker.circuit_breaker.CircuitBreakerStrategy object>

Default Circuit Breaker Strategy provided for convenience which has the following values configured by default. Detailed information on Circuit Breakers and their configuration can be found at the link (https://oracle-cloud-infrastructure-python-sdk.readthedocs.io/en/latest/sdk_behaviors/circuit_breakers.html)

  • failure_threshold - 10

  • recovery_timeout - 30 seconds

  • failure_statuses_and_codes

    • HTTP 409/IncorrectState
    • HTTP 429
    • HTTP 500
    • HTTP 502
    • HTTP 503
    • HTTP 504

Circuit Breakers

Classes

CircuitBreakerStrategy(**kwargs) A class which can build a circuit breaker strategy based on provided criteria.
NoCircuitBreakerStrategy() A class which represents that no circuit breaker strategy is to be used for the Client.

Data

DEFAULT_CIRCUIT_BREAKER_STRATEGY Default Circuit Breaker Strategy provided for convenience which has the following values configured by default.
GLOBAL_CIRCUIT_BREAKER_STRATEGY A Circuit Breaker strategy which can be set by the user to modify the SDK retry behavior globally.
class oci.circuit_breaker.CircuitBreakerStrategy(**kwargs)

A class which can build a circuit breaker strategy based on provided criteria.

This builder is intended as a convenience, but callers are also able to bypass this and construct circuit breaker strategies directly.

Parameters:
  • failure_threshold (int) – (optional) The failure_threshold parameter specifies the number of subsequent failures that causes to circuit breaker to move from CLOSED to OPEN state. This parameter takes an integer value with 10 being the default value.
  • recovery_timeout (int) – (optional) The recovery timeout is the time in seconds that the circuit breaker waits till it moves from an OPEN to HALF-OPEN state. This parameter takes in an integer with 30 seconds being the default value.
  • failure_statuses_and_codes (dict) –

    (optional) This parameter takes in a dict object of type (int, list(str)) which consist of the status code and the list of error codes the circuit breaker takes in account for failure threshold. If the list of error code is an empty list the circuit breaker would mark all errors as failure which has that specific status code regardless of the error code.

    defaults to: {

    409: [‘IncorrectState’], 429: [], 500: [], 502: [], 503: [], 504: []

    }

  • name (str) – (optional) The name of Circuit Breaker. Each circuit breaker instance is by internally made unique to a client. This makes sure that a circuit breaker of one client does not interfere with the operations of the other clients, even if they belong to the same service. In a rare case, when it is intended to share the same Circuit Breaker across multiple clients, a CircuitBreakerStrategy object can be made with the name value set as desired and passed to the clients meant to share the circuit breaker. In this scenario failures from any client add to the failure threshold of the circuit breaker shared by all clients.

Methods

__init__(**kwargs) Creates a new builder and initializes it based on any provided parameters.
is_transient_error(status_code, service_code)
__init__(**kwargs)

Creates a new builder and initializes it based on any provided parameters.

is_transient_error(status_code, service_code)
class oci.circuit_breaker.NoCircuitBreakerStrategy

A class which represents that no circuit breaker strategy is to be used for the Client.

Methods

__init__() Initialize self.
__init__()

Initialize self. See help(type(self)) for accurate signature.

oci.circuit_breaker.DEFAULT_CIRCUIT_BREAKER_STRATEGY = <oci.circuit_breaker.circuit_breaker.CircuitBreakerStrategy object>

Default Circuit Breaker Strategy provided for convenience which has the following values configured by default. Detailed information on Circuit Breakers and their configuration can be found at the link (https://oracle-cloud-infrastructure-python-sdk.readthedocs.io/en/latest/sdk_behaviors/circuit_breakers.html)

  • failure_threshold - 10

  • recovery_timeout - 30 seconds

  • failure_statuses_and_codes

    • HTTP 409/IncorrectState
    • HTTP 429
    • HTTP 500
    • HTTP 502
    • HTTP 503
    • HTTP 504
oci.circuit_breaker.GLOBAL_CIRCUIT_BREAKER_STRATEGY = None

A Circuit Breaker strategy which can be set by the user to modify the SDK retry behavior globally. Initially set to None, users can pass to it a Circuit Breaker Strategy which can be:-

  • A Circuit Breaker Strategy built using oci.circuit_breaker.CircuitBreakerStrategy class
  • The oci.circuit_breaker.DEFAULT_CIRCUIT_BREAKER_STRATEGY
  • oci.circuit_breaker.NoCircuitBreakerStrategy() which will disable Circuit Breaker at SDK level

A helpful environment variable OCI_SDK_DEFAULT_CIRCUITBREAKER_ENABLED is also provided to enable/disable default circuit breakers for the SDK