Skip to main content

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)

Source distribution for ice-rules 4.0.12
File Size Uploaded
ice_rules-4.0.12.tar.gz 35.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ice-rules 4.0.12
File Interpreter ABI Platform
ice_rules-4.0.12-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

4.0.12 This release

2 release files

4.0.11

2 release files

4.0.10

2 release files

4.0.8

2 release files

4.0.7

2 release files

4.0.6

2 release files

4.0.5

2 release files

4.0.4

2 release files

4.0.3

2 release files

4.0.2

2 release files

4.0.1

2 release files

4.0.0

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.1.3

2 release files

2.1.2

2 release files

2.1.0

2 release files

2.0.9

2 release files

2.0.8

2 release files

2.0.7

2 release files

2.0.6

2 release files

2.0.5

2 release files

2.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page