-
Notifications
You must be signed in to change notification settings - Fork 736
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start from workflows branch, squashed
- Loading branch information
Showing
43 changed files
with
1,279 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# worker-ts | ||
|
||
## 0.0.1 | ||
|
||
### Patch Changes | ||
|
||
- [#3588](https://github.com/cloudflare/workers-sdk/pull/3588) [`64631d8b`](https://github.com/cloudflare/workers-sdk/commit/64631d8b59572f49d65325d8f6fec098c5e912b9) Thanks [@penalosa](https://github.com/penalosa)! - fix: Preserve email handlers when applying middleware to user workers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "my-workflow", | ||
"private": true, | ||
"scripts": { | ||
"deploy": "wrangler deploy", | ||
"start": "wrangler dev --x-dev-env" | ||
}, | ||
"devDependencies": { | ||
"@cloudflare/workers-types": "^4.20240909.0", | ||
"wrangler": "workspace:*" | ||
}, | ||
"volta": { | ||
"extends": "../../package.json" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { | ||
WorkerEntrypoint, | ||
Workflow, | ||
WorkflowEvent, | ||
WorkflowStep, | ||
} from "cloudflare:workers"; | ||
|
||
type Params = { | ||
name: string; | ||
}; | ||
export class Demo extends Workflow<{}, Params> { | ||
async run(events: Array<WorkflowEvent<Params>>, step: WorkflowStep) { | ||
const { timestamp, payload } = events[0]; | ||
const result = await step.do("First step", async function () { | ||
return { | ||
output: "First step result", | ||
}; | ||
}); | ||
|
||
await step.sleep("Wait", "1 minute"); | ||
|
||
const result2 = await step.do("Second step", async function () { | ||
return { | ||
output: "Second step result", | ||
}; | ||
}); | ||
|
||
return { | ||
result, | ||
result2, | ||
timestamp, | ||
payload, | ||
}; | ||
} | ||
} | ||
|
||
type Env = { | ||
WORKFLOW: { | ||
create: (id: string) => { | ||
pause: () => {}; | ||
}; | ||
}; | ||
}; | ||
export default class extends WorkerEntrypoint<Env> { | ||
async fetch() { | ||
const handle = await this.env.WORKFLOW.create(crypto.randomUUID()); | ||
await handle.pause(); | ||
return new Response(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es2021", | ||
"lib": ["es2021"], | ||
"module": "es2022", | ||
"types": ["@cloudflare/workers-types/experimental"], | ||
"noEmit": true, | ||
"isolatedModules": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"skipLibCheck": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#:schema node_modules/wrangler/config-schema.json | ||
name = "my-workflow-demo" | ||
main = "src/index.ts" | ||
compatibility_date = "2024-09-02" | ||
compatibility_flags = ["experimental"] | ||
|
||
[[workflows]] | ||
binding = "WORKFLOW" | ||
name = "my-workflow" | ||
class_name = "Demo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.