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.set_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.set_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
Metadata
Release files for ice-rules 4.0.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ice_rules-4.0.12.tar.gz | 35.4 kB | Without provenance | Details for ice_rules-4.0.12.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ice_rules-4.0.12-py3-none-any.whl | Python 3 | none | any | Details for ice_rules-4.0.12-py3-none-any.whl |
Total release size: 78.7 kB
Release files / ice_rules-4.0.12.tar.gz
| Download URL | ice_rules-4.0.12.tar.gz |
|---|---|
| Size | 35.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c23d906a2b96af61128a53465fa63c885145f9414cd02b2f4826a0843a26b613
|
|
BLAKE2b-256 checksum How to use checksums |
361ce3310a09b86dbca181a11242329f18be3bd01f609b13bba0c1e9dffb1b3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Release files / ice_rules-4.0.12-py3-none-any.whl
| Download URL | ice_rules-4.0.12-py3-none-any.whl |
|---|---|
| Size | 43.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4cb682864068d650d129ce2ca4007f09a04c6b104e16e4b79f29ee89a3db56be
|
|
BLAKE2b-256 checksum How to use checksums |
319a01acf2c6670ca210643069d7bc2c6a3790429dca7dc911adf2c438e0f45b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Security for ice-rules 4.0.12
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.