Help us shape the future of Go! Take the 2026 Go Developer Survey

fixture

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package fixture provides the seeded Temporal workflows that tests run against a dev server.

Index

Constants

View Source
const (

	// PaymentsTaskQueue is the task queue of the ProcessLedgerEntry activities for the payments domain.
	PaymentsTaskQueue = "ledger-payments"

	// RecoveryWorkerIdentity is the identity of the worker that NewRecoveryWorker returns.
	RecoveryWorkerIdentity = "recovery-worker"
)
View Source
const (
	// LedgerTaskQueue is the task queue of the stuck ledger workflows and their activities.
	LedgerTaskQueue = "ledger"
	// StuckWorkerIdentity is the identity of the worker that NewStuckWorker returns.
	StuckWorkerIdentity = "stuck-worker"
	// StuckLedgerWorkflowID is the ID of the stuck ledger workflow that starts three activities.
	StuckLedgerWorkflowID = "ledger-reconciliation-main"
	// StuckLedgerActivities is the number of activities that the stuck ledger workflows start together.
	StuckLedgerActivities = 7
)
View Source
const TaskQueue = "orders-demo"

TaskQueue is the task queue the order workflow runs on.

Variables

This section is empty.

Functions

func NewFulfillmentWorker

func NewFulfillmentWorker(c client.Client, version int) worker.Worker

NewFulfillmentWorker returns an unstarted worker that runs version 1 or 2 of FulfillmentWorkflow on fulfillmentTaskQueue, and no activities. Version 1 starts a PrepareShippingLabel activity on the shipping branch and then waits forever. Version 2 only waits, so once it runs, the next workflow task of a run that took the shipping branch, such as one for a deployment_probe signal, fails as nondeterministic.

func NewIncidentWorker

func NewIncidentWorker(c client.Client) worker.Worker

NewIncidentWorker returns an unstarted worker that runs ledgerEntryWorkflow on incidentTaskQueue, and no activities: while no recovery worker runs, the incident goes on and no ProcessLedgerEntry activity starts.

func NewRecoveryWorker

func NewRecoveryWorker(c client.Client) worker.Worker

NewRecoveryWorker returns an unstarted worker, with identity RecoveryWorkerIdentity, that runs the ProcessLedgerEntry activities on PaymentsTaskQueue, which ends the incident for the payments domain. The first attempt of each fails with LedgerServiceUnavailable and the next succeeds; a terminal entry's fails with the non-retryable LedgerWriteRejected.

func NewStuckWorker

func NewStuckWorker(c client.Client) worker.Worker

NewStuckWorker returns an unstarted worker that polls LedgerTaskQueue for workflow tasks only, so no FetchLedgerBatch activity ever starts.

func NewWorker

func NewWorker(c client.Client) worker.Worker

NewWorker returns an unstarted worker for TaskQueue with OrderWorkflow and its activities registered.

func OrderWorkflow

func OrderWorkflow(ctx workflow.Context, order OrderInput) (map[string]string, error)

OrderWorkflow authorizes payment for an order, then enriches its product from the catalog, making up to three attempts RetryIntervalSeconds apart.

func StartFailedOrder

func StartFailedOrder(ctx context.Context, c client.Client) (client.WorkflowRun, error)

StartFailedOrder starts order 88231 as workflow order-88231 with OrderId 88231. Its catalog activity fails on all three attempts, so the workflow fails.

func StartFulfillment

func StartFulfillment(ctx context.Context, c client.Client, id string, shippingBranch bool) (client.WorkflowRun, error)

StartFulfillment starts FulfillmentWorkflow as workflow id.

func StartLedgerEntry

func StartLedgerEntry(ctx context.Context, c client.Client, id string, entry LedgerEntry) (client.WorkflowRun, error)

StartLedgerEntry starts ledgerEntryWorkflow for entry as workflow id, with search attribute Domain set to its domain.

func StartStuckLedger

func StartStuckLedger(ctx context.Context, c client.Client) error

StartStuckLedger starts reconcileLedgerWorkflow as StuckLedgerWorkflowID with three batches and as two more workflows with two batches each.

Types

type LedgerEntry

type LedgerEntry struct {
	Domain   string `json:"domain"`
	Terminal bool   `json:"terminal"`
}

LedgerEntry is the input of ledgerEntryWorkflow.

type OrderInput

type OrderInput struct {
	OrderID              string `json:"order_id"`
	CatalogShouldFail    bool   `json:"catalog_should_fail"`
	RetryIntervalSeconds int    `json:"retry_interval_seconds"`
}

OrderInput is the input of OrderWorkflow.

Jump to

Keyboard shortcuts

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