Metadata-Version: 2.4
Name: ufaflow
Version: 1.0.8
Summary: UfaFlow
Author: halif
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: PyYAML>=6.0
Dynamic: author
Dynamic: license-file

<h1 align="center">UfaFlow</h1>

<p align="center">
  <a href="https://pypi.org/project/ufaflow/"><img src="https://img.shields.io/pypi/v/ufaflow?style=for-the-badge" alt="PyPI version" /></a>
  <img src="https://img.shields.io/pyversions/ufaflow?style=for-the-badge" alt="Python versions" />
  <a href="https://github.com/halif/UfaFlow/actions/workflows/ci.yml"><img src="https://github.com/halif/UfaFlow/actions/workflows/ci.yml/badge.svg?branch=main&event=push" alt="CI status" /></a>
  <a href="https://github.com/halif/UfaFlow/releases/latest"><img src="https://img.shields.io/github/v/release/halif/UfaFlow?style=for-the-badge" alt="Latest release" /></a>
</p>

UfaFlow is a lightweight, asynchronous worker manager and load balancer for Python services. It runs from a YAML configuration, supports single-process and multi-worker modes, and provides a status command for runtime checks.

## Requirements

- Python 3.11 or newer
- Linux or macOS for full multi-worker support
- Windows is supported for single-process usage

## Installation

Install the latest published version from PyPI:

```bash
python -m pip install --upgrade ufaflow
```

On Windows, you can use a virtual environment:

```powershell
py -3.11 -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade ufaflow
```

## Quick start

Create a file named `config.yaml`:

```yaml
frontends:
  - name: local
    listen_host: "127.0.0.1"
    listen_port: 8080
    algorithm: round_robin
    backends:
      - host: "127.0.0.1"
        port: 8001
      - host: "127.0.0.1"
        port: 8002
```

Start UfaFlow with one worker:

```bash
python -m ufaflow.cli config.yaml
```

On Linux or macOS, you can start multiple worker processes:

```bash
python -m ufaflow.cli config.yaml --workers 4
```

The configured backend services should be running and reachable at the listed host and port addresses. Stop the process with `Ctrl+C`.

## Check backend status

UfaFlow can check whether the configured backend ports accept a TCP connection and print a JSON report:

```bash
python -m ufaflow.cli status config.yaml
```

The report's overall status is `ok` when all checked backends are reachable and `degraded` when one or more are unavailable. This command checks TCP connectivity, not HTTP or application-level health.

## Troubleshooting

If something does not work as expected, see [docs/TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md) for the most common setup and runtime issues.

## Run from a source checkout

After cloning the repository, install the project and test dependencies, then run the test suite:

```bash
python -m pip install -e . pytest
python -m pytest -q
```

## License

MIT. See the [LICENSE](LICENSE) file.
