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_roam_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()
pack = ice.Pack(ice_id=1)
pack.roam.put("score", 85)
results = ice.sync_process(pack)
client.destroy()
3. 异步方式
import asyncio
async def main():
client = ice.AsyncFileClient(app=1, storage_path="./ice-data")
await client.start()
pack = ice.Pack(ice_id=1)
pack.roam.put("score", 85)
results = await ice.async_process(pack)
await client.destroy()
asyncio.run(main())
叶子节点类型
Flow 类型(返回 True/False)
do_flow(ctx: Context) -> booldo_pack_flow(pack: Pack) -> booldo_roam_flow(roam: Roam) -> bool
Result 类型(返回 True/False)
do_result(ctx: Context) -> booldo_pack_result(pack: Pack) -> booldo_roam_result(roam: Roam) -> bool
None 类型(无返回值)
do_none(ctx: Context) -> Nonedo_pack_none(pack: Pack) -> Nonedo_roam_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-2.0.6.tar.gz
(30.3 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-2.0.6-py3-none-any.whl
(37.8 kB
view details)
File details
Details for the file ice_rules-2.0.6.tar.gz.
File metadata
- Download URL: ice_rules-2.0.6.tar.gz
- Upload date:
- Size: 30.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10ca64735b07164af1f2451671d2275c8d65251882af81d20c5a1be5352f22bb
|
|
| MD5 |
7610d8c81b0cf10839354586847ed589
|
|
| BLAKE2b-256 |
2e04763ffc4c10b945db5a9f5eccae06595ae394e20801e3a89cb7ac8a7f5d2f
|
File details
Details for the file ice_rules-2.0.6-py3-none-any.whl.
File metadata
- Download URL: ice_rules-2.0.6-py3-none-any.whl
- Upload date:
- Size: 37.8 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 |
b0f320e32d5958cd8d74272cb78bc55cd243ac1b2366d6277186fa9d67837bcc
|
|
| MD5 |
efbc1e726a6c47b3a3ff2b4fe486b023
|
|
| BLAKE2b-256 |
06263da804596919e52f898d275b525a0c50b947add95e30afd720856c05fa23
|