Skip to main content

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.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

Project details


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.6.tar.gz (35.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ice_rules-4.0.6-py3-none-any.whl (43.3 kB view details)

Uploaded Python 3

File details

Details for the file ice_rules-4.0.6.tar.gz.

File metadata

  • Download URL: ice_rules-4.0.6.tar.gz
  • Upload date:
  • Size: 35.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for ice_rules-4.0.6.tar.gz
Algorithm Hash digest
SHA256 987d8da7b0aaa4cfc8392fc4bb3095b50dcf011c86d23edf2f97b108ec7c78f2
MD5 f226cc7c8582c930c382f2794ea5df11
BLAKE2b-256 01d007dfabaeff76919cc2a09920680b9c5d635d4f6e4e65538503a8afd0cec2

See more details on using hashes here.

File details

Details for the file ice_rules-4.0.6-py3-none-any.whl.

File metadata

  • Download URL: ice_rules-4.0.6-py3-none-any.whl
  • Upload date:
  • Size: 43.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for ice_rules-4.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 32d28923d73b89d468bc3789e4206feadff4e510803eb413886c603b62c2cb03
MD5 a00815413addfe89b48e5a245ef45fd3
BLAKE2b-256 fcfbc5096cfb2d1222d06ab5b1c5464ad320be25b42b55c79132094eab242cf1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page