dtssample

package
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: 10 Imported by: 0

Documentation

Overview

Package dtssample holds the Durable Task Scheduler setup that most runnable samples in this repository share: reading connection settings from the environment, opening a management client, and starting a worker against the same task hub.

Point the samples at a scheduler with a connection string, for example the local emulator:

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

Index

Constants

View Source
const ConnectionStringVariable = "DTS_CONNECTION_STRING"

ConnectionStringVariable names the environment variable used by the connection-string-driven samples to locate their DTS task hub.

Variables

This section is empty.

Functions

func Cleanup

func Cleanup(client *durabletaskscheduler.Client, instanceIDs ...api.InstanceID) error

Cleanup terminates and purges only the supplied, sample-owned instance IDs and their children. Call it before shutting down the worker. Entity state, schedules, export jobs, and storage objects need their own sample-specific cleanup.

func NewInstanceID

func NewInstanceID(sample string) api.InstanceID

NewInstanceID gives each sample run its own orchestration namespace.

func Options

func Options() (*durabletaskscheduler.Options, error)

Options builds scheduler options from ConnectionStringVariable.

func RequireCompleted

func RequireCompleted(metadata *api.OrchestrationMetadata) error

RequireCompleted rejects unsuccessful terminal states as well as missing results.

Types

type App

type App struct {
	// Client schedules orchestrations and reads their state.
	Client *durabletaskscheduler.Client
	// contains filtered or unexported fields
}

App owns a Durable Task Scheduler client and worker pair that are connected to the same task hub.

func Start

func Start(
	ctx context.Context,
	registry *task.TaskRegistry,
	workerOptions ...durabletaskclient.TaskHubGrpcWorkerOption,
) (*App, error)

Start connects a client and starts a worker for registry against the task hub named by ConnectionStringVariable. The caller owns the returned App and must call App.Shutdown.

The worker derives its work-item filters from registry; pass additional workerOptions to layer more behavior on top.

func StartWithOptions

func StartWithOptions(
	ctx context.Context,
	options *durabletaskscheduler.Options,
	registry *task.TaskRegistry,
	workerOptions ...durabletaskclient.TaskHubGrpcWorkerOption,
) (*App, error)

StartWithOptions is Start for a sample that customizes its options, such as enabling versioning or large payloads.

func (*App) Shutdown

func (a *App) Shutdown() error

Shutdown stops the worker and closes the client. It uses a background deadline so it still runs to completion once the sample's context is done.

Jump to

Keyboard shortcuts

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