コンテンツにスキップ
Developer Preview — APIs and language features may change before 1.0

lifecycle

このコンテンツはまだ日本語訳がありません。

Block: hooks/config for machine lifecycle (start, stop)

  • en: lifecycle
  • de: Lebenszyklus
  • es: ciclo de vida
  • fr: cycle de vie
  • ja: ライフサイクル
  • ko: 생명주기
  • zh: 生命周期

Example — Loops, schedules and parallel work

Section titled “Example — Loops, schedules and parallel work”

Builds a daily digest: runs on a schedule, works through a list, does two things at once, repeats until done, starts another machine and waits for an answer.

machine daily_digest
accepts
urls as list of text, is required
responds with
summary as text
behaves
runtime
timeout: 5000
lifecycle
on_start: warm
schedules
daily: "07:00"
run gather
go to deliver
flows
flow gather
for each url in input.urls
accumulate pages from []
compute fetch_one
{page: url}
together
flow
compute part_a
{x: 1}
flow
compute part_b
{y: 2}
while spin loop.c < 3
accumulate c from 0
compute bump
{c: loop.c + 1}
until steps.bump.c > 2
compute retry_bump
{c: steps.bump.c + 1}
flow deliver
match input.urls
when []
{summary: "nothing to send"}
otherwise
{summary: "digest ready"}
launch notifier
target: mail_service
wait for approval
event: "digest.approved"
publish "digest.sent"
on failure
compute recover
{summary: "failed"}
ensures
permissions
allowed to
call
event.publish
verifies
test "gathers pages and delivers the digest"
assuming notifier {launched: true}
given {urls: ["https://a.com"]}
resuming approval
with {approved: true} as "[email protected]"
expect {summary: "digest ready"}