Latency and fault tolerance for distributed systems

Wiliam Souza 9876b39980 Merge pull request #1 from wiliamsouza/feature/metrics il y a 5 ans
docs 4ef00d163e Rename ExecutorMetrics to PoolMetrics and update Poll and PoolMetrics docs il y a 9 ans
hystrix 3800655905 Fix command property initialization il y a 9 ans
tests 5b2c6c16ff Change test class name to py.test stop trying run it il y a 6 ans
.coveragerc 2f73609c19 Add CHANGES.md and .coveragerc il y a 9 ans
.gitignore 015526b3c4 Rename Executor to Pool il y a 9 ans
.travis.yml 508248cba5 Change travis to use tox il y a 6 ans
AUTHORS 8f39438dd3 Added LICENSE and AUTHORS il y a 9 ans
CHANGES.md 2f73609c19 Add CHANGES.md and .coveragerc il y a 9 ans
LICENSE 8f39438dd3 Added LICENSE and AUTHORS il y a 9 ans
MANIFEST.in ba0d7f33d5 Added CHANGES.md to MANIFEST.in il y a 9 ans
Makefile 46ec459ac4 Updated scripts Makefile, tox.ini and setup.py il y a 9 ans
README.md c638e47f09 Updated README add WIP note il y a 9 ans
repos.sh 3a36f32504 Added repos conf script il y a 10 ans
setup.cfg 92435e4896 Initial commit il y a 10 ans
setup.py a77a68da9a Merge branch 'master' into feature/metrics il y a 6 ans
tox.ini aa0b970717 Update tox envlist il y a 6 ans

README.md

hystrix-py

Build Status Coverage Status Documentation Status

A Netflix Hystrix port to Python.

This is a work in progress, please feel free to help!

What is Hystrix?

For more information see the Netflix Hystrix Wiki documentation.

How it works

To know more see the Netflix Hystrix Wiki How it works section documentation.

Features

It's ALPHA version and only support launching a group of commands inside an executor pool.

  • Execute synchronous commands.
  • Execute asynchronous commands.
  • Execute asynchronous commands and attach a callback.

Requirements

It depends on concurrent.futures, new in Python version 3.2 and enum, new in Python version 3.4. It uses futures and enum34 backports to run in Python version 2.7, 3.3 and 3.4.

Installation

Create a virtualenv:

mkproject --python=<fullpath_to_python_3.2+> hystrix-py

Get the code:

git clone https://github.com/wiliamsouza/hystrix-py .

Install it:

python setup.py develop

The last command enter your code in "Development Mode" it creates an egg-link in your virtualenv's site-packages making it available on this environment sys.path. For more info see setuptools development-mode

Development and test dependencies

setup.py will handle test dependencies, to install development use:

pip install -e .[dev]

Tests

python setup.py test

Hello world

Code to be isolated is wrapped inside the run() method of a hystrix.Command similar to the following:

from hystrix import Command

class HelloWorldCommand(Command):
    def run(self):
        return 'Hello World'

This command could be used like this:

command = HelloCommand()

# synchronously
print(command.execute())
'Hello World'

# asynchronously
future = command.queue()
print(future.result())
'Hello Wold'

# callback
def print_result(future)
     print(future.result())

future = command.observe()
future.add_done_callback(print_result)

LICENSE

Copyright 2015 Hystrix Python Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.