@@ -19,7 +19,7 @@ check if they were already charged:
1919
2020``` ts
2121export class MyWorkflow extends WorkflowEntrypoint {
22- async run(event : WorkflowEvent , step : WorkflowStep ) {
22+ async run(event : WorkflowEvent < Params > , step : WorkflowStep ) {
2323 const customer_id = 123456 ;
2424 // ✅ Good: Non-idempotent API/Binding calls are always done **after** checking if the operation is
2525 // still needed.
@@ -69,7 +69,7 @@ You can also think of it as a transaction, or a unit of work.
6969
7070``` ts
7171export class MyWorkflow extends WorkflowEntrypoint {
72- async run(event : WorkflowEvent , step : WorkflowStep ) {
72+ async run(event : WorkflowEvent < Params > , step : WorkflowStep ) {
7373 // ✅ Good: Unrelated API/Binding calls are self-contained, so that in case one of them fails
7474 // it can retry them individually. It also has an extra advantage: you can control retry or
7575 // timeout policies for each granular step - you might not to want to overload http.cat in
@@ -94,7 +94,7 @@ Otherwise, your entire Workflow might not be as durable as you might think, and
9494
9595``` ts
9696export class MyWorkflow extends WorkflowEntrypoint {
97- async run(event : WorkflowEvent , step : WorkflowStep ) {
97+ async run(event : WorkflowEvent < Params > , step : WorkflowStep ) {
9898 // 🔴 Bad: you're calling two seperate services from within the same step. This might cause
9999 // some extra calls to the first service in case the second one fails, and in some cases, makes
100100 // the step non-idempotent altogether
@@ -120,7 +120,7 @@ function getRandomInt(min, max) {
120120}
121121
122122export class MyWorkflow extends WorkflowEntrypoint {
123- async run(event : WorkflowEvent , step : WorkflowStep ) {
123+ async run(event : WorkflowEvent < Params > , step : WorkflowStep ) {
124124 // 🔴 Bad: `imageList` will be not persisted across engine's lifetimes. Which means that after hibernation,
125125 // `imageList` will be empty again, even though the following two steps have already ran.
126126 const imageList: string [] = [];
@@ -163,7 +163,7 @@ function getRandomInt(min, max) {
163163}
164164
165165export class MyWorkflow extends WorkflowEntrypoint {
166- async run(event : WorkflowEvent , step : WorkflowStep ) {
166+ async run(event : WorkflowEvent < Params > , step : WorkflowStep ) {
167167 // ✅ Good: imageList state is exclusively comprised of step returns - this means that in the event of
168168 // multiple engine lifetimes, imageList will be built accordingly
169169 const imageList: string [] = await Promise .all ([
@@ -231,7 +231,7 @@ Dynamically naming a step will prevent it from being cached, and cause the step
231231
232232` ` ` ts
233233export class MyWorkflow extends WorkflowEntrypoint {
234- async run(event : WorkflowEvent , step : WorkflowStep ) {
234+ async run(event : WorkflowEvent < Params > , step : WorkflowStep ) {
235235 // 🔴 Bad: Dynamically naming the step prevents it from being cached
236236 // This will cause the step to be re-run if subsequent steps fail.
237237 await step .do (` step #1 running at: ${Date .now } ` , async () => {
0 commit comments