-
Notifications
You must be signed in to change notification settings - Fork 131
Standalone activity API sketches #1138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
a1d3efe
to
23df3f8
Compare
temporalio/client.py
Outdated
self._id_or_token = ActivityIDReference(activity_id=id, run_id=run_id) | ||
self.run_id = run_id | ||
|
||
# TODO: do we support something like `follow_runs: bool`? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need there's no concept of an execution chain for activities.
handle = await self.start_activity(*args, **kwargs) | ||
return await handle.result() | ||
|
||
async def list_activities( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be interesting to see how we can model this to return both workflow and standalone "client" activities.
|
||
# - TODO: Overloads for no-param, single-param, multi-param | ||
# - TODO: Support sync and async activity functions | ||
async def start_activity( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also need execute_activity
but we can leave that for later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually execute_activity
is already present below.
temporalio/client.py
Outdated
|
||
|
||
@dataclass(frozen=True) | ||
class AsyncActivityIDReference: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider deprecating and renaming to WorkflowActivityIDReference
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or merging the two reference types where workflow_id
becomes an optional field.
temporalio/client.py
Outdated
"""Handle representing an activity started by a workflow.""" | ||
|
||
def __init__( | ||
self, client: Client, id_or_token: Union[AsyncActivityIDReference, bytes] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should work with any activity IMHO.
temporalio/client.py
Outdated
self._id_or_token = id_or_token | ||
|
||
|
||
WorkflowActivityHandle = AsyncActivityHandle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will also need pause
, reset
, etc...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we still want AsyncActivityHandle
because you can obtain one with a token and can't do anything else with the token but issue completion requests.
""" | ||
raise NotImplementedError | ||
|
||
# TODO: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also TODO: all of the async completion methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean heartbeat
, complete
, fail
, and report_cancellation
, right? Those are all inherited from _BaseActivityHandle
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm on the fence whether we want to expose these methods on the activity handle as opposed to having the async completion handle as a separate concept. The use cases are different for the two.
temporalio/client.py
Outdated
) | ||
|
||
|
||
# TODO: This name is suboptimal now. We could deprecate it and introduce WorkflowActivityHandle as a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, let's do that. Which means that you would have to accept a WorkflowActivityHandle
where you accept AsyncActivityHandle
.
temporalio/client.py
Outdated
|
||
class AsyncActivityHandle: | ||
"""Handle representing an external activity for completion and heartbeat.""" | ||
class _BaseActivityHandle: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would consider just duplicating instead of inheriting but don't have a strong opinion.
2f29d96
to
519a359
Compare
4760964
to
0904987
Compare
No description provided.