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

Add client.trigger #18

Merged
merged 6 commits into from
Nov 11, 2024
Merged

Add client.trigger #18

merged 6 commits into from
Nov 11, 2024

Conversation

CahidArda
Copy link
Collaborator

Adds a method for triggering workflows which returns the workflow run id. It is now possible to:

  • pass your own workflow run id
  • receive the final workflow run id as result
const { workflowRunId } await client.trigger({
  url: "https://workflow-endpoint.com",
  body: "hello there!", // optional body
  headers: { ... }, // optional headers
  workflowRunId: "my-workflow", // optional workflow run id
  retries: 3 // optional retries in the initial request
})

console.log(workflowRunId)
// prints wfr_my-workflow

the result workflow run id will always have wfr_ prefix.

Workflow Run Id Selection

when passing a workflow run id, users should use a different workflow run id used everytime. Otherwise, there could be issues in the console view. In the image below, finished workflow runs show RUN_STARTED because another run is ongoing with the same id:

image

We will try to address this issue.

Copy link

linear bot commented Nov 7, 2024

const context = new WorkflowContext({
qstashClient: this.client,
// @ts-expect-error headers type mismatch
headers: new Headers(headers ?? {}),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
headers: new Headers(headers ?? {}),
headers: new Headers((headers ?? {}) as Record<string, string>),

sth like this would probably work

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

issue is not headers ?? {} not being a valid parameter for Headers, it's the incompatibility of Headers with headers:

Type 'Headers' is missing the following properties from type 'Headers': toJSON, count, getAll

@CahidArda CahidArda merged commit b7e6116 into main Nov 11, 2024
1 check passed
@CahidArda CahidArda deleted the DX-1404-trigger-workflow branch November 11, 2024 13:20
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.

2 participants