ENF News Bot
Automated News Bot
- Joined
- Apr 15, 2022
- Messages
- 2,591
Workflows now provides additional context inside
The
ReadableStream support in
https://developers.cloudflare.com/changelog/rss/#readablestream-support-in-stepdo
Steps can now return a
Note that streamed outputs are still considered part of the Workflow instance storage limit.
Continue reading...
step.do() callbacks and supports returning ReadableStream to handle larger step outputs.Step context properties
https://developers.cloudflare.com/changelog/rss/#step-context-propertiesThe
step.do() callback receives a context object with new properties alongside attempt:step.name— The name passed tostep.do()step.count— How many times a step with that name has been invoked in this instance (1-indexed)- Useful when running the same step in a loop.
config— The resolved step configuration, includingtimeoutandretrieswith defaults applied
Code:
type ResolvedStepConfig = {
retries: {
limit: number;
delay: WorkflowDelayDuration | number;
backoff?: "constant" | "linear" | "exponential";
};
timeout: WorkflowTimeoutDuration | number;
};
type WorkflowStepContext = {
step: {
name: string;
count: number;
};
attempt: number;
config: ResolvedStepConfig;
};
ReadableStream support in step.do()
https://developers.cloudflare.com/changelog/rss/#readablestream-support-in-stepdoSteps can now return a
ReadableStream directly. Although non-stream step outputs are limited to 1 MiB, streamed outputs support much larger payloads.
Code:
const largePayload = await step.do("fetch-large-file", async () => {
const object = await env.MY_BUCKET.get("large-file.bin");
return object.body;
});
Note that streamed outputs are still considered part of the Workflow instance storage limit.
Continue reading...