Skip to content
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

Update cancel method #26

Merged
merged 5 commits into from
Nov 19, 2024
Merged

Update cancel method #26

merged 5 commits into from
Nov 19, 2024

Conversation

CahidArda
Copy link
Collaborator

@CahidArda CahidArda commented Nov 15, 2024

update client.cancel to cancel all workflows or cancel a set of workflows or based on a workflow url

There are multiple ways you can cancel workflows:

  • pass one or more workflow run ids to cancel them
  • pass a workflow url to cancel all runs starting with this url
  • don't pass any options. in this case, all workflow will be canceled

Cancel a set of workflow runs

// cancel a single workflow
await client.cancel({ ids: "<WORKFLOW_RUN_ID>" })

// cancel a set of workflow runs
await client.cancel({ ids: [
  "<WORKFLOW_RUN_ID_1>",
  "<WORKFLOW_RUN_ID_2>",
]})

Cancel workflows starting with a url

If you have an endpoint called https://your-endpoint.com and you
want to cancel all workflow runs on it, you can use urlStartingWith.

Note that this will cancel workflows in all endpoints under
https://your-endpoint.com.

await client.cancel({ urlStartingWith: "https://your-endpoint.com" })

Cancel all workflows

If you want to cancel all workflows under your user, you can
do it like this:

await client.cancel({ all: true })

@joschan21
Copy link
Contributor

joschan21 commented Nov 15, 2024

wdyt about offering the following 3 options for the cancel interface

  • ids?: string | string[]
  • urlStartingWith?: string for url-based cancellation, more clear about the "starting with" behavior
  • all?: boolean to cancel all pending runs

@fahreddinozcan
Copy link
Collaborator

I think cancelling all on await client.cancel() would allow people to make mistakes while cancelling. It's also not that intuitive. I'd agree with client.cancel({all: true})

@CahidArda
Copy link
Collaborator Author

all parameter sounds good. Updating parameters like this:

type CancelOptions = {
  workflowRunId?: string | string[];
  workflowUrl?: string;
  all?: true;
};

@joschan21
Copy link
Contributor

what about the rest?

@CahidArda
Copy link
Collaborator Author

got tunnel visioned with all :D

others make sense too, updated the pr.

Copy link
Contributor

@joschan21 joschan21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

src/client/index.ts Outdated Show resolved Hide resolved
src/client/index.ts Outdated Show resolved Hide resolved
@CahidArda CahidArda merged commit 2937841 into main Nov 19, 2024
17 checks passed
@CahidArda CahidArda deleted the client-cancel-workflow branch November 19, 2024 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants