Skip to content

Commit

Permalink
add purge api (#34)
Browse files Browse the repository at this point in the history
Signed-off-by: Fabian Martinez <[email protected]>
  • Loading branch information
famarting authored Oct 29, 2024
1 parent 8598f6b commit c17a3e8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### New

- Support for orchestration custom status ([#31](https://github.com/microsoft/durabletask-python/pull/31)) - contributed by [@famarting](https://github.com/famarting)
- Added `set_custom_status` orchestrator API ([#31](https://github.com/microsoft/durabletask-python/pull/31)) - contributed by [@famarting](https://github.com/famarting)
- Added `purge_orchestration` client API ([#34](https://github.com/microsoft/durabletask-python/pull/34)) - contributed by [@famarting](https://github.com/famarting)

### Updates

Expand Down
5 changes: 5 additions & 0 deletions durabletask/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,8 @@ def resume_orchestration(self, instance_id: str):
req = pb.ResumeRequest(instanceId=instance_id)
self._logger.info(f"Resuming instance '{instance_id}'.")
self._stub.ResumeInstance(req)

def purge_orchestration(self, instance_id: str, recursive: bool = True):
req = pb.PurgeInstancesRequest(instanceId=instance_id, recursive=recursive)
self._logger.info(f"Purging instance '{instance_id}'.")
self._stub.PurgeInstances()
3 changes: 3 additions & 0 deletions tests/test_orchestration_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ def child(ctx: task.OrchestrationContext, _):
assert state is not None
assert state.runtime_status == client.OrchestrationStatus.TERMINATED

task_hub_client.purge_orchestration(id)
state = task_hub_client.get_orchestration_state(id)
assert state is None


def test_continue_as_new():
Expand Down

0 comments on commit c17a3e8

Please sign in to comment.