examples

package
v1.42.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package examples — workflow patterns that exercise the Hanzo Tasks engine end-to-end via the native ZAP SDK at pkg/sdk/client. Zero go.temporal.io/* and zero google.golang.org/grpc imports.

The samples run against an embedded tasksd boot (see _test.go) so they double as the integration test corpus for every shipped release.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CronResult

type CronResult struct {
	ScheduleID  string
	ListedCount int
	Paused      bool
	Resumed     bool
}

func Cron

func Cron(ctx context.Context, c client.Client, _ string) (*CronResult, error)

Cron creates a schedule, lists schedules, pauses + unpauses it, then deletes it.

type EmbedResult added in v1.41.0

type EmbedResult struct {
	Port          int
	HealthService string
	HealthStatus  string
	StartedID     string
	StartedRunID  string
	ListedCount   int
}

EmbedResult captures the lifecycle of an in-process daemon dial.

func Embed added in v1.41.0

func Embed(ctx context.Context) (*EmbedResult, error)

Embed boots tasks.Embed in-process on an ephemeral port, dials it via pkg/sdk/client, and round-trips Health → ExecuteWorkflow → ListWorkflows. This is the canonical "single binary" pattern Base apps use when TASKS_EMBED=true; the sample exercises the same code path so a regression in either the Embed boot or the SDK dial would trip the test suite immediately.

type HelloResult

type HelloResult struct {
	StartedID    string
	StartedRunID string
	BeforeStatus int
	AfterStatus  int
	ListedCount  int
}

Hello starts a no-input workflow and confirms its execution record is round-trippable across the full client surface: ExecuteWorkflow → DescribeWorkflow → ListWorkflows → CancelWorkflow → DescribeWorkflow.

The returned Result captures the lifecycle so tests can assert on each transition without re-issuing the calls.

func Hello

func Hello(ctx context.Context, c client.Client, namespace string) (*HelloResult, error)

Hello drives the basic workflow lifecycle. It never blocks on workflow completion (the engine doesn't execute user code yet); it only verifies the control-plane round-trips end-to-end.

type RealtimeResult added in v1.41.0

type RealtimeResult struct {
	StartedCount int
	EventsCaught int
	StartEvents  int
	CancelEvents int
}

RealtimeResult captures what arrived on the SSE stream during the demo window: every workflow.* event for the workflows we started.

func Realtime added in v1.41.0

func Realtime(parent context.Context) (*RealtimeResult, error)

Realtime boots an embedded daemon, opens an SSE subscription via the native pkg/sdk/client.SubscribeEvents helper, fires a few state-changing operations, and tallies the events it observed before the context expires.

This proves the realtime pipeline end-to-end: engine → broker → SSE → SDK channel → caller. No proxy, no gRPC, no upstream client.

type SignalResult

type SignalResult struct {
	WorkflowID    string
	RunID         string
	HistoryBefore int64
	HistoryAfter  int64
	FinalStatus   int
}

SignalResult captures the lifecycle of a signal-driven workflow.

func Signal

func Signal(ctx context.Context, c client.Client, _ string) (*SignalResult, error)

Signal drives a workflow + a signal + a terminate. The engine doesn't run the workflow's signal channel goroutine yet, but the history length must increment on each signal.

Jump to

Keyboard shortcuts

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