Metadata-Version: 2.4
Name: ruleflow-sdk
Version: 0.1.0
Summary: Decision Engine SDK for RuleFlow — evaluate published business rules with in-memory caching.
License-Expression: MIT
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx
Dynamic: license-file

# ruleflow-sdk

Python SDK for [RuleFlow](https://github.com/) — evaluate published business
rules from your application, with in-memory caching so repeated evaluations
don't hit the network every time.

## Install

```bash
pip install ruleflow-sdk
```

## Usage

```python
from ruleflow_sdk import DecisionEngine

# Create once (e.g. at app startup) and reuse — it holds an in-memory cache.
engine = DecisionEngine(
    base_url="https://your-ruleflow-backend.example.com",
    api_key="your-ruleflow-api-key",
    cache_ttl_seconds=60,  # optional, defaults to 60
)

result = engine.evaluate("premium_pod_limit", {"plan": "premium", "country": "india"})
if result:
    max_pods = result["max_pods"]
else:
    max_pods = default_limit  # conditions didn't match
```

`evaluate(rule_id, context)`:
- Fetches the rule's published DSL (cached for `cache_ttl_seconds` — repeat
  calls within that window never hit the network).
- Evaluates the conditions locally against `context`.
- Returns the rule's action dict if matched, else `None`.
- Records an analytics event on the backend (fire-and-forget — never raises,
  even if the backend is briefly unreachable).

`refresh(rule_id=None)` — force-bust the cache for one rule, or all cached
rules, instead of waiting out the TTL.

## Requirements

- Python >= 3.10
- A running RuleFlow backend, reachable from wherever this SDK is used, with
  the target rule already published.

## License

MIT — see [LICENSE](./LICENSE).
