new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Temporal · Develop · all subjects

timers and sleeps

8 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Workflow timeouts in temporal CLI

Temporal CLI supports three timeout flags for workflow execution: --execution-timeout (fail a WorkflowExecution if it lasts longer than DURATION, includes retries and ContinueAsNew tasks), --run-timeout (fail a Workflow Run if it lasts longer than DURATION), and --task-timeout (fail a Workflow Task if it lasts longer than DURATION, this is the Start-to-close timeout for a Workflow Task). All are specified as duration values.

Use Workflow.DelayAsync instead of Task.Delay in .NET

To wait in a workflow, use Workflow.DelayAsync instead of Task.Delay or Thread.Sleep.

.NET Workflow.WaitConditionAsync for condition-based waiting

Use Workflow.WaitConditionAsync for waiting based on conditions instead of .NET built-in timers or timeout-based CancellationTokenSource.

Use Selectors to race Activity against Timer for soft timeout

An important use case of Selectors with Futures is setting up a race between a timer and a pending activity, effectively adding a soft timeout that does not result in errors or retries of that activity. If processing takes too long, you can send a notification, but if the operation finishes before the timer fires, you can cancel the timer.

Create timers with workflow.NewTimer(ctx, duration)

Timers in Temporal Go Workflows are created with the workflow.NewTimer API, which takes a context and duration.

Selector with Activity and Timer race example

Example showing how to race an Activity against a Timer for a soft timeout: ```go var processingDone bool f := workflow.ExecuteActivity(ctx, OrderProcessingActivity) selector.AddFuture(f, func(f workflow.Future) { processingDone = true // cancel timerFuture cancelHandler() }) // use timer future to send notification email if processing takes too long timerFuture := workflow.NewTimer(childCtx, processingTimeThreshold) selector.AddFuture(timerFuture, func(f workflow.Future) { if !processingDone { // processing is not done yet when timer fires, send notification email _ = workflow.ExecuteActivity(ctx, SendEmailActivity).Get(ctx, nil) } }) // wait the timer or the order processing to finish selector.Select(ctx) ```

PHP Workflow time and timer usage

Only use Workflow::now() to get the current time inside a Workflow. Call yield Workflow::timer() instead of sleep().

Waiting in Ruby Workflows

Use Temporalio::Workflow.sleep instead of Kernel#sleep to wait in Workflow code.

Give your agent this brain