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-3.0.2.tar.gz
(30.6 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-3.0.2-py3-none-any.whl
(38.2 kB
view details)
File details
Details for the file ice_rules-3.0.2.tar.gz.
File metadata
- Download URL: ice_rules-3.0.2.tar.gz
- Upload date:
- Size: 30.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d23b921f536bd9b65a34743ffa461ed2eb44d1c4e3a51025850010cf7b78b8ff
|
|
| MD5 |
f2cb38e15d07665b1f6a98f9682c2dbe
|
|
| BLAKE2b-256 |
c26994f8025cc8b2a346132ca6e49e0e73a647cd6b48bea660f66028198d62dc
|
File details
Details for the file ice_rules-3.0.2-py3-none-any.whl.
File metadata
- Download URL: ice_rules-3.0.2-py3-none-any.whl
- Upload date:
- Size: 38.2 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 |
139323d5788ba28ceaf40deb136cbe5c598a740b73c999e7f1d1975cae9d17f6
|
|
| MD5 |
88a97cb607219107424a27160f0ff2c1
|
|
| BLAKE2b-256 |
b5ce49a8c20879d73fd64bc6307b239e00e84f6d7fefc0fa81e2c86d73a032f8
|