Ice Rule Engine Python SDK
Project description
Ice Python SDK
Ice 规则引擎的 Python 实现,与 Java ice-core 和 Go SDK 功能一致。
安装
pip install ice-rules
快速开始
1. 注册叶子节点
import ice
from ice import Roam
@ice.leaf("com.example.ScoreFlow")
class ScoreFlow:
threshold: int = 0
def do_flow(self, roam: Roam) -> bool:
return roam.get_int("score", 0) >= self.threshold
2. 启动客户端
# 同步方式
client = ice.FileClient(app=1, storage_path="./ice-data")
client.start()
roam = ice.Roam.create()
roam.get_meta().id = 1
roam.put("score", 85)
results = ice.sync_process(roam)
client.destroy()
3. 异步方式
import asyncio
async def main():
client = ice.AsyncFileClient(app=1, storage_path="./ice-data")
await client.start()
roam = ice.Roam.create()
roam.get_meta().id = 1
roam.put("score", 85)
results = await ice.async_process(roam)
await client.destroy()
asyncio.run(main())
叶子节点类型
Flow 类型(返回 True/False)
do_flow(roam: Roam) -> bool
Result 类型(返回 True/False)
do_result(roam: Roam) -> bool
None 类型(无返回值)
do_none(roam: Roam) -> None
版本要求
- Python >= 3.11
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ice_rules-4.0.0.tar.gz
(35.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
ice_rules-4.0.0-py3-none-any.whl
(44.3 kB
view details)
File details
Details for the file ice_rules-4.0.0.tar.gz.
File metadata
- Download URL: ice_rules-4.0.0.tar.gz
- Upload date:
- Size: 35.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fc7e918af49d7ef538908732642b7a8558f76fef67d169e038bee40a2e2bbfd
|
|
| MD5 |
931b1c155885fd70ce5f844a1513d4ec
|
|
| BLAKE2b-256 |
1c94b3a73cad7fc2d518dadddae551052b2742e4e4907f8a1a04b28c3a5a2050
|
File details
Details for the file ice_rules-4.0.0-py3-none-any.whl.
File metadata
- Download URL: ice_rules-4.0.0-py3-none-any.whl
- Upload date:
- Size: 44.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff779aba7f80928f5794ac89b891a86df58c8fc7a1dca8b4d30fa329036fd6c6
|
|
| MD5 |
689b86534bf3430c9aff83776aef1fb3
|
|
| BLAKE2b-256 |
be2cd8e7dbca2920403b3574da148f48d9b805d4eae2f42b5b24292de13e91d2
|