Python framework for Cadence Workflow Service
Project description
Python framework for Cadence Workflow Service
Cadence is a workflow engine developed at Uber Engineering. With this framework, workflows and activities managed by Cadence can be implemented in Python code.
Status / TODO
cadence-python is still under going heavy development. It should be considered EXPERIMENTAL at the moment. A production
version is targeted to be released in September of 2019 January 2020.
- Tchannel implementation
- Python-friendly wrapper around Cadence's Thrift API
- Author activities in Python
- Start workflows (synchronously)
- Create workflows
- Workflow execution in coroutines
- Invoke activities from workflows
- Activity heartbeating and doNotCompleteOnReturn
- Activity retry
- Signals
- Queries
- Async workflow execution
- await
- now (currentTimeMillis)
- Timers
- Sleep
- Loggers
- newRandom
- UUID
- Workflow Versioning
2.0
- Sticky workflows
Post 2.0:
- sideEffect/mutableSideEffect
- Parallel activity execution
- Cancellation Scopes
- Child Workflows
Installation
pip install cadence-client
Hello World Sample
import sys
import logging
from cadence.activity_method import activity_method
from cadence.workerfactory import WorkerFactory
from cadence.workflow import workflow_method, Workflow, WorkflowClient
logging.basicConfig(level=logging.DEBUG)
TASK_LIST = "HelloActivity-python-tasklist"
DOMAIN = "sample"
# Activities Interface
class GreetingActivities:
@activity_method(task_list=TASK_LIST, schedule_to_close_timeout_seconds=2)
def compose_greeting(self, greeting: str, name: str) -> str:
raise NotImplementedError
# Activities Implementation
class GreetingActivitiesImpl:
def compose_greeting(self, greeting: str, name: str):
return greeting + " " + name + "!"
# Workflow Interface
class GreetingWorkflow:
@workflow_method(execution_start_to_close_timeout_seconds=10, task_list=TASK_LIST)
async def get_greeting(self, name: str) -> str:
raise NotImplementedError
# Workflow Implementation
class GreetingWorkflowImpl(GreetingWorkflow):
def __init__(self):
self.greeting_activities: GreetingActivities = Workflow.new_activity_stub(GreetingActivities)
async def get_greeting(self, name):
return await self.greeting_activities.compose_greeting("Hello", name)
if __name__ == '__main__':
factory = WorkerFactory("localhost", 7933, DOMAIN)
worker = factory.new_worker(TASK_LIST)
worker.register_activities_implementation(GreetingActivitiesImpl(), "GreetingActivities")
worker.register_workflow_implementation_type(GreetingWorkflowImpl)
factory.start()
client = WorkflowClient.new_client(domain=DOMAIN)
greeting_workflow: GreetingWorkflow = client.new_workflow_stub(GreetingWorkflow)
result = greeting_workflow.get_greeting("Python")
print(result)
print("Stopping workers....")
worker.stop()
print("Workers stopped...")
sys.exit(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
cadence-client-0.0.2.tar.gz
(43.6 kB
view details)
Built Distribution
File details
Details for the file cadence-client-0.0.2.tar.gz
.
File metadata
- Download URL: cadence-client-0.0.2.tar.gz
- Upload date:
- Size: 43.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c753a750a83a17e251244e07819b3c26c4aebb3272b7e02564452068539f9221 |
|
MD5 | 319450cb3fa516d6c12c10f304b2821e |
|
BLAKE2b-256 | deeb0f214afae699ca8e1b970084e7f4a85cf9b1df04fe56a93723867c8b4f81 |
File details
Details for the file cadence_client-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: cadence_client-0.0.2-py3-none-any.whl
- Upload date:
- Size: 50.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b9a33c94b048e11a45a5c74817a9cdcdf6c929ab5eaeae054e634e401755acd |
|
MD5 | 951dec180cd02e7561129252f1bd7fc7 |
|
BLAKE2b-256 | 72df8ffda8ad98ab12b2717fafa5555f22d4fd02df7cd953e76620291385b892 |