Optionaloptions: HTTPWorkflowOptionsimport { WorkflowEntrypoint } from "cloudflare:workers";
import { withHTTPWorkflow } from "@grand-board/otel-cloudflare";
class MyWorkflowBase extends WorkflowEntrypoint<Env, MyParams> {
async run(event: WorkflowEvent<MyParams>, step: WorkflowStep) {
const data = await step.do("fetch-data", async () => {
return await fetchData();
});
return { success: true, data };
}
}
// Apply the mixin
export const MyWorkflow = withHTTPWorkflow(MyWorkflowBase);
// Worker fetch handler:
export default {
async fetch(request, env, ctx) {
return MyWorkflow.fetch(request, env.MY_WORKFLOW);
}
}
Mixin to add HTTP endpoints and automatic tracing to a Cloudflare Workflow class
This mixin wraps the workflow's
runmethod with:It also adds a static
fetchmethod for HTTP access: