Skip to content

yaojianpin/acts-channel-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

acts-channel

Acts-channel is a workflow client to connect to acts-server

Usage

Before connecting, please download acts-server and start it

pip install acts-channel

Example

import signal
import sys
import time

from acts_channel import Channel


def signal_handler(signal, frame):
    print('Caught Ctrl+C / SIGINT signal')
    sys.exit(0)

def main():
    chan = Channel(url = "127.0.0.1:10080")
    signal.signal(signal.SIGINT, signal_handler)
    model = """
    id: test
    name: workflow in python
    ver: 0.1.0
    steps:
        - name: step 1
          id: step1
          uses: acts.core.irq
          params:
            key: abc
    """
    resp = chan.deploy(model)

    ret = resp.unwrap_or_raise(ValueError)
    print("chan.deploy:", ret)

    resp = chan.send("model:get", { "id": "test", "fmt": "tree"})
    print(resp.ok_value["data"])

    chan.subscribe("client-1", on_message)

    resp = chan.start("test", { "custom": "aaa" })
    print(resp.ok_value)

    print("waiting for all messages...")
    time.sleep(5)

def on_message(chan: Channel, message):
    print(f"on_message: {message}")
    if message["key"] == "abc":
        chan.act("complete", message["pid"], message["tid"], {})


if __name__ == "__main__":
    main()

About

acts server client in python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages