Skip to content

import { WorkflowEntrypoint, WorkflowStep } from "cloudflare:workers"; #3186

@flynnjustin24

Description

@flynnjustin24

import { WorkflowEntrypoint, WorkflowStep } from "cloudflare:workers";
import type { WorkflowEvent } from "cloudflare:workers";

type Params = { name: string };
type IPResponse = { result: { ipv4_cidrs: string[] } };

export class MyWorkflow extends WorkflowEntrypoint<Env, Params> {
async run(event: WorkflowEvent, step: WorkflowStep) {
const data = await step.do("fetch data", async () => {
const response = await fetch("https://api.cloudflare.com/client/v4/ips");
return await response.json();
});

await step.sleep("pause", "20 seconds");

const result = await step.do(
  "process data",
  { retries: { limit: 3, delay: "5 seconds", backoff: "linear" } },
  async () => {
    return {
      name: event.payload.name,
      ipCount: data.result.ipv4_cidrs.length,
    };
  },
);

return result;

}
}

Originally posted by @flynnjustin24 in flynnjustin24/skills-hello-github-action#6 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions