Metadata-Version: 2.4
Name: matelabdev-watcher-client
Version: 1.0.0
Summary: Matelabdev Watcher heartbeat client for Python applications
License-Expression: MIT
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.28
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: responses>=0.25; extra == "dev"

# matelabdev-watcher-client

Python heartbeat client for [Matelabdev Watcher](https://github.com/matelabdev/watcher).

## Install

```bash
pip install matelabdev-watcher-client
```

## Usage

```python
from matelabdev_watcher import WatcherClient

watcher = WatcherClient(
    master_url="https://watcher.example.com",
    token="prj_xxxxxxxxxxxx",
    monitor_key="lens-app",
    interval=30,
)
watcher.start()   # daemon thread — stops automatically when process exits
```

### Manual ping

```python
watcher.ping()    # single one-off heartbeat
watcher.stop()    # stop the background thread
```

## Environment variables (recommended)

```python
import os
from matelabdev_watcher import WatcherClient

watcher = WatcherClient(
    master_url=os.environ["WATCHER_URL"],
    token=os.environ["WATCHER_TOKEN"],
    monitor_key=os.environ.get("WATCHER_MONITOR_KEY", "app"),
)
watcher.start()
```

## Behavior

- Heartbeats are fire-and-forget — failures are silently suppressed so your app is never affected.
- The background thread is a daemon, so it exits automatically when the main process ends.
- Calling `start()` multiple times is safe (idempotent).
