All Projects → last9 → pyhystrix

last9 / pyhystrix

Licence: MIT license
Hystrix brought to Python

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to pyhystrix

yato
A node module similar to hystrix. Who caused riots - cut it!
Stars: ✭ 12 (-42.86%)
Mutual labels:  hystrix, circuit-breaker
microservices-developer-roadmap
Roadmap for becoming a Microservice Developer in 2017
Stars: ✭ 24 (+14.29%)
Mutual labels:  hystrix, circuit-breaker
Hystrix.Dotnet
A combination of circuit breaker and timeout. The .net version of the open source Hystrix library built by Netflix.
Stars: ✭ 88 (+319.05%)
Mutual labels:  hystrix, circuit-breaker
Brakes
Hystrix compliant Node.js Circuit Breaker Library
Stars: ✭ 255 (+1114.29%)
Mutual labels:  hystrix, circuit-breaker
Sample Camel Spring Boot
three samples in different branches that illustrates usage of apache camel as microservice framework providing integration with consul, hystrix, ribbon and other tools
Stars: ✭ 24 (+14.29%)
Mutual labels:  hystrix, circuit-breaker
spring-microservices
Spring Cloud Micro Services with Eureka Discovery, Zuul Proxy, OAuth2 Security, Hystrix CircuitBreaker, Sleuth Zipkin, ELK Stack Logging, Kafka, Docker and many new features
Stars: ✭ 114 (+442.86%)
Mutual labels:  hystrix, circuit-breaker
clj-http-hystrix
A Clojure library to wrap clj-http requests as hystrix commands
Stars: ✭ 21 (+0%)
Mutual labels:  hystrix, circuit-breaker
Opossum
Node.js circuit breaker - fails fast ⚡️
Stars: ✭ 473 (+2152.38%)
Mutual labels:  hystrix, circuit-breaker
Connectors
Connectors simplify connecting to standalone and CloudFoundry services
Stars: ✭ 28 (+33.33%)
Mutual labels:  hystrix, circuit-breaker
Heimdall
An enhanced HTTP client for Go
Stars: ✭ 2,132 (+10052.38%)
Mutual labels:  hystrix, circuit-breaker
gobreak
Latency and fault tolerance library like Netflix's Hystrix with prometheus and gobreaker.
Stars: ✭ 42 (+100%)
Mutual labels:  hystrix, circuit-breaker
scala-circuit-breaker
A circuit breaker for Scala applications and services
Stars: ✭ 34 (+61.9%)
Mutual labels:  circuit-breaker
CircuitBreaker
A Swift Circuit Breaker library – Improves application stability and reliability.
Stars: ✭ 42 (+100%)
Mutual labels:  circuit-breaker
laravel-circuit-breaker
An implementation of the circuit breaker pattern for Laravel 5.6
Stars: ✭ 26 (+23.81%)
Mutual labels:  circuit-breaker
circuit-breaker
PHP implementation of circuit breaker pattern
Stars: ✭ 17 (-19.05%)
Mutual labels:  circuit-breaker
envoy-proxy-demos
Set of Envoy Proxy feature demos (Envoy v2 API supported)
Stars: ✭ 63 (+200%)
Mutual labels:  circuit-breaker
spring-boot-learn-box
spring boot集成其他组件
Stars: ✭ 21 (+0%)
Mutual labels:  hystrix
lua-circuit-breaker
Circuit breaker pattern in Lua
Stars: ✭ 28 (+33.33%)
Mutual labels:  circuit-breaker
Sentinel-Dashboard-Nacos
Description Sentinel Dashboard使用NACOS作为数据源持久化规则。【仅用于教学,如用于生产,请务必做好测试!】
Stars: ✭ 87 (+314.29%)
Mutual labels:  circuit-breaker
Uragano
Uragano, A simple, high performance RPC library. Support load balancing, circuit breaker, fallback, caching, intercepting.
Stars: ✭ 28 (+33.33%)
Mutual labels:  circuit-breaker

pyhystrix

A library to patch requests package in order to add following functionalities by default:

  • Connection and Read timeouts
  • Retries on connection failure
  • Circuitbreaking
  • Adding unique x-request-id in request header if not provided

NOTE:: 0.0.2 supports python2.7 and >= 0.0.3 supports python3 only.

Installation

pip3 install pyhystrix

Usage

Before making any request, just call Init():

import requests
import pyhystrix
requests.get("http://abc.xyx") // No functionalities of pyhystrix
pyhystrix.Init()
requests.get("http://abc.xyx") // pyhystrix is attached to all requests

Default Configurations can be changed in 2 ways:

  1. Setting following env variables:

    • PHY_CONNECT_TIMEOUT : connection timeout in sec
    • PHY_READ_TIMEOUT: read timeout in seconds
    • PHY_MAX_RETRIES: max number of retries for connection failure
    • PHY_CIRCUIT_FAIL_THRESHOLD: Number of failed requests after which circuit will be open and further requests on the same url will not be allowed.
    • PHY_CIRCUIT_ALIVE_THRESHOLD: Number of failed requests on open circuit to make it half_open (Described below)
    • PHY_CIRCUIT_DELAY: Number of seconds after which open circuit will be half_open.
  2. parameters in request itself:

    • max_tries(int): overrides PHY_MAX_RETRIES, some rules related to it are follows:
      • max_tries=0: will cause no retries, fail on first failure.
      • If a positive value is passed for non GET requests, they will be retried too in case received status is in status_forcelist.
    • status_forcelist: list of http status, retry if the returned status is one of these. default is [500] on GET.
    • timeout: same as timeout in requests
    • backoff_factor: delay in each retry will be affected by this using following formula: {backoff factor} * (2 ^ ({number of total retries} - 1)). Default = 0.5sec

More Examples

  • GET with retry on multiple failure status codes:
import requests
import pyhystrix
pyhystrix.Init()
request.get("http://abc.xyz", status_forcelist=[501, 502, 403])
  • put with retry on response status = 500 or 501
request.put("http://abc.xyz", max_tries=3, status_forcelist=[500, 502])

NOTE: All type of requests will be retried in case of ConnectionError

Circuit Breaker States

  1. OPEN : No requests will be allowed
  2. HALF_OPEN : Only one request will be allowed
  3. CLOSE : All requests will be allowed.

NOTE : State transitions:

CLOSE --> OPEN --> HALF_OPEN --> CLOSE/OPEN

To know more about circuit breaker pattern, click here

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].