coroutines

command
v1.0.0-beta.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Coroutines sample

Features

  • Starts bounded orchestration coroutines with ctx.Go.
  • Coordinates coroutine completion with ctx.NewWaitGroup.
  • Uses Select on a typed event channel and a durable timer from a child cancellation scope.
  • Cancels the losing timer when the approval event wins.
  • Validates the returned doubled values and selected event outcome.

Prerequisites

Start a Durable Task Scheduler endpoint or emulator and set:

export DTS_CONNECTION_STRING="Endpoint=http://localhost:8080;TaskHub=default;Authentication=None"

Run

go run ./samples/coroutines

Expected result

The host raises the Approval event after the orchestration starts. The event wins over the durable timer, the timer scope is canceled, three activity-backed coroutines return 4, 8, and 12, and the sum is verified as 24. On success it prints:

SAMPLE_OK coroutines

Cleanup

The sample terminates if needed and recursively purges only its generated sample-coroutines-* orchestration instance before shutting down.

Noninteractive command

DTS_CONNECTION_STRING="$DTS_CONNECTION_STRING" go run ./samples/coroutines

Documentation

Overview

Command coroutines demonstrates orchestration coroutines, durable wait groups, Select, and child cancellation scopes.

export DTS_CONNECTION_STRING="Endpoint=http://localhost:8080;TaskHub=default;Authentication=None"
go run ./samples/coroutines

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL