temporal

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 19 Imported by: 0

README

Temporal Package

A thin integration layer over the Temporal Go SDK (go.temporal.io/sdk), providing client construction with functional options, convenience managers for workers, schedules, and workflow queries, and a zerolog logger adapter.

SDK-Integration Posture

This package intentionally exposes go.temporal.io/sdk types in its public API — client.Client, worker.Worker, client.ScheduleHandle, and so on. It is not an abstraction layer over the Temporal SDK:

  • NewClient returns a real client.Client; every SDK capability stays available.
  • The managers (WorkerManager, ScheduleManager, WorkflowManager) are convenience lifecycle wrappers — they collect workers/schedules, add structured logging, and offer ready-made query helpers. You can always drop down to the SDK client directly (each manager exposes GetClient()).
  • For typed, per-workflow handles (register, execute, describe, cancel, schedule — all scoped to one workflow definition), use the temporal/job package's Definition instead of the generic managers.

If the SDK can do it, you can do it through the client this package hands you.

Features

  • Client (client.go) — NewClient(opts ...Option) builds a client.Client from DefaultConfig() with functional options; optional OTel tracing interceptor and metrics handler.
  • WorkerManager (worker.go) — register and start worker.Workers on a shared client; Close(ctx) stops all workers.
  • ScheduleManager (schedule.go) — create, list, update, and delete workflow schedules (cron, intervals).
  • WorkflowManager (workflow.go) — query, monitor, and control workflow executions (list/search/describe, cancel/terminate/signal/query, dashboard stats).
  • ZerologAdapter (logger.go) — bridges a zerolog.Logger into the Temporal SDK's log.Logger interface.
  • job (./job) — typed per-workflow Definition with register/execute/query/schedule operations.
  • testcontainer (./testcontainer) — spin up a Temporal server in Docker for integration tests.

Installing

go get github.com/jasoet/pkg/v3/temporal

Quick Start

1. Create a Client

NewClient starts from DefaultConfig() (localhost:7233, namespace default) and applies options in order. The caller owns the returned client — close it with client.Close().

package main

import (
    "github.com/jasoet/pkg/v3/temporal"
)

func main() {
    // Defaults: localhost:7233, namespace "default"
    c, err := temporal.NewClient()
    if err != nil {
        panic(err)
    }
    defer c.Close()

    // Or with options:
    c, err = temporal.NewClient(
        temporal.WithHostPort("temporal.example.com:7233"),
        temporal.WithNamespace("production"),
        // temporal.WithOTelConfig(otelCfg),  // attach OTel tracing/metrics
        // temporal.WithConfig(myConfig),     // or replace the whole Config
    )
    if err != nil {
        panic(err)
    }
    defer c.Close()
}
Options
Option Effect
WithConfig(c Config) Replace the entire configuration with c
WithHostPort(addr) Set the Temporal frontend address (host:port)
WithNamespace(ns) Set the Temporal namespace
WithOTelConfig(otelCfg) Attach OTel tracing interceptor and metrics handler
WithTLS(tlsCfg) Connect over TLS (required for Temporal Cloud / TLS-enabled servers)
WithCredentials(creds) Authenticate the client (e.g. Temporal Cloud API key via client.NewAPIKeyStaticCredentials, or mTLS)
WithClientOptions(fn) Escape hatch: mutate the assembled client.Options before dialing for any SDK option not surfaced above

If tracing is explicitly enabled via WithOTelConfig and the tracing interceptor cannot be constructed, NewClient returns that error instead of silently proceeding without tracing.

Connecting to Temporal Cloud:

c, err := temporal.NewClient(
    temporal.WithHostPort("your-namespace.a1b2c.tmprl.cloud:7233"),
    temporal.WithNamespace("your-namespace.a1b2c"),
    temporal.WithTLS(&tls.Config{}),
    temporal.WithCredentials(client.NewAPIKeyStaticCredentials("<api-key>")),
)
2. Manage Workers

NewWorkerManager takes an existing client.Client. The caller retains ownership of the client: WorkerManager.Close(ctx) stops the registered workers but never closes the client.

c, err := temporal.NewClient()
if err != nil {
    panic(err)
}
defer c.Close()

wm, err := temporal.NewWorkerManager(c)
if err != nil {
    panic(err)
}
defer wm.Close(ctx) // stops workers; does NOT close c

w := wm.Register("my-task-queue", worker.Options{})
w.RegisterWorkflow(MyWorkflow)
w.RegisterActivity(MyActivity)

if err := wm.StartAll(ctx); err != nil {
    panic(err)
}
3. Query and Monitor Workflows

NewWorkflowManager(c) inherits the namespace the client was configured with, so every operation (list, count, history, describe, cancel, …) agrees on the namespace. Use NewWorkflowManagerWithNamespace(c, ns) only to scope the visibility queries (ListWorkflows/CountWorkflows) to a different namespace; the other operations still target the client's namespace. The manager has no Close — there is nothing to release; the client is caller-owned.

wfm, err := temporal.NewWorkflowManagerWithNamespace(c, "production")
if err != nil {
    panic(err)
}

// Dashboard statistics
stats, err := wfm.GetDashboardStats(ctx)
fmt.Printf("Running: %d, Completed: %d, Failed: %d\n",
    stats.TotalRunning, stats.TotalCompleted, stats.TotalFailed)

// List / search
running, err := wfm.ListRunningWorkflows(ctx, 100)
orders, err := wfm.SearchWorkflowsByType(ctx, "OrderProcessingWorkflow", 50)

// Details and lifecycle
details, err := wfm.DescribeWorkflow(ctx, "order-123", "")
err = wfm.CancelWorkflow(ctx, "problematic-workflow-id", "")
4. Schedule Workflows

NewScheduleManager also takes a caller-owned client; Close(ctx) only logs — it never closes the client.

sm, err := temporal.NewScheduleManager(c)
if err != nil {
    panic(err)
}
defer sm.Close(ctx)

handle, err := sm.CreateWorkflowSchedule(ctx, "hourly-report", temporal.WorkflowScheduleOptions{
    WorkflowID: "report-workflow",
    Workflow:   ReportWorkflow,
    TaskQueue:  "reports",
    Interval:   time.Hour,
    Args:       []any{"daily-report"},
})
5. Typed Per-Workflow Handles (temporal/job)

For application workflows, prefer a job.Definition: it binds a workflow type to its name, task queue, registration, and execution, and gives you typed operations scoped to that workflow — including schedules whose ID equals the definition name.

import "github.com/jasoet/pkg/v3/temporal/job"

def, err := job.New("report", "reports",
    job.WithRegister(func(w worker.Worker) {
        w.RegisterWorkflow(ReportWorkflow)
    }),
    job.WithExecute(func(ctx context.Context, c client.Client, opts client.StartWorkflowOptions, input any) (client.WorkflowRun, error) {
        return c.ExecuteWorkflow(ctx, opts, ReportWorkflow, input)
    }),
    job.WithNewInput(func() any { return ReportInput{} }),
    job.WithSchedule(&job.ScheduleSpec{Interval: time.Hour}),
)

See the job package for Register, Execute, Describe, Cancel, ApplySchedule, ListRuns, and more.

ZerologAdapter

ZerologAdapter adapts a zerolog.Logger to the Temporal SDK's log.Logger interface, so SDK internal logs flow into your zerolog pipeline. NewClient wires one up automatically; construct your own when you dial the SDK directly:

import (
    "github.com/rs/zerolog"
    "go.temporal.io/sdk/client"

    "github.com/jasoet/pkg/v3/temporal"
)

zlog := zerolog.New(os.Stderr).With().Timestamp().Logger()
c, err := client.Dial(client.Options{
    HostPort:  "localhost:7233",
    Namespace: "default",
    Logger:    temporal.NewZerologAdapter(zlog),
})

It supports Debug/Info/Warn/Error with key-value pairs (odd keyvals are tolerated), With(...) for derived loggers, and WithCallerSkip(skip).

Client Ownership and Lifecycle

  • NewClient returns a client.Client that you own — always defer c.Close().
  • NewWorkerManager(c), NewScheduleManager(c), NewWorkflowManager(c) / NewWorkflowManagerWithNamespace(c, ns) borrow the client; they never close it.
  • WorkerManager.Close(ctx) stops all registered workers; ScheduleManager.Close(ctx) is a logging-only no-op. Both take a context.Context used for logging only.
  • WorkflowManager has no Close — it holds no resources beyond the borrowed client.

Examples

Runnable examples live in examples/temporal:

  • Dashboard — HTTP dashboard for monitoring workflows
  • Worker — worker setup patterns
  • Workflows — sample workflow implementations
  • Scheduler — scheduling workflows

The workflows, activities, worker, and scheduler example packages are guarded by the example build tag:

go build -tags=example ./examples/temporal/...

The dashboard (examples/temporal/dashboard/main.go) is the exception: it is a real main package deliberately left untagged so it can be run directly with go run (see below).

Running the Dashboard Example
cd examples/temporal/dashboard
go run main.go

# Or with custom configuration
TEMPORAL_HOST=temporal.example.com:7233 \
TEMPORAL_NAMESPACE=production \
go run main.go

Then open http://localhost:8080 in your browser.

API Reference

WorkflowManager Methods
Query Operations
  • ListWorkflows(ctx, pageSize, query) — list workflows with optional filtering
  • ListRunningWorkflows(ctx, pageSize) / ListCompletedWorkflows(ctx, pageSize) / ListFailedWorkflows(ctx, pageSize) — list by status
  • ListWorkflowsByStatus(ctx, status, pageSize) — list by an explicit status
  • DescribeWorkflow(ctx, workflowID, runID) — detailed workflow information
  • GetWorkflowStatus(ctx, workflowID, runID) — current status
  • GetWorkflowHistory(ctx, workflowID, runID) — workflow event history
Search Operations
  • SearchWorkflowsByType(ctx, workflowType, pageSize) — find by workflow type
  • SearchWorkflowsByID(ctx, idPrefix, pageSize) — find by workflow ID prefix
  • CountWorkflows(ctx, query) — count workflows matching a query
Lifecycle Operations
  • CancelWorkflow(ctx, workflowID, runID) — cancel a running workflow
  • TerminateWorkflow(ctx, workflowID, runID, reason) — terminate a workflow
  • SignalWorkflow(ctx, workflowID, runID, signalName, data) — send a signal
  • QueryWorkflow(ctx, workflowID, runID, queryType, args) — query workflow state
Dashboard Operations
  • GetDashboardStats(ctx) — aggregated workflow statistics
  • GetRecentWorkflows(ctx, limit) — most recent workflows
  • GetWorkflowResult(ctx, workflowID, runID, valuePtr) — workflow result

Visibility-query parameters passed to ListWorkflowsByStatus, SearchWorkflowsByType, and SearchWorkflowsByID are validated against a safe-identifier pattern (alphanumerics, hyphens, underscores, dots).

Testing

The package has two test tiers:

  • Unit tests (no tag) — config/options, zerolog adapter, query validation, and manager behavior with mock clients:

    go test ./temporal/ -count=1
    
  • Integration tests (//go:build integration) — full suites against a real Temporal server managed by testcontainers (client, worker, schedule, workflow, e2e):

    go test -tags=integration -timeout=10m ./temporal/...
    # or via Taskfile
    task test:integration
    

Prerequisites for integration tests: Docker. Each suite gets its own isolated temporalio/temporal container; no manual server setup is required.

Testcontainer Package

The temporal/testcontainer package provides reusable utilities for running a Temporal server in Docker containers for integration testing. It can be used in your own projects too.

go get github.com/jasoet/pkg/v3/temporal/testcontainer

Simple setup (recommended):

import (
    "context"
    "testing"

    "github.com/jasoet/pkg/v3/temporal/testcontainer"
)

func TestMyWorkflow(t *testing.T) {
    ctx := context.Background()

    _, c, cleanup, err := testcontainer.Setup(
        ctx,
        testcontainer.ClientConfig{Namespace: "default"},
        testcontainer.Options{Logger: t},
    )
    if err != nil {
        t.Fatalf("Setup failed: %v", err)
    }
    defer cleanup()

    // Use c (a client.Client) for your tests...
}

Advanced setup (manual container management, dial the SDK yourself):

container, err := testcontainer.Start(ctx, testcontainer.Options{
    Image:          "temporalio/temporal:1.22.0",
    StartupTimeout: 120 * time.Second,
    Logger:         t,
})
if err != nil {
    t.Fatalf("Failed to start: %v", err)
}
defer container.Terminate(ctx)

temporalClient, err := client.Dial(client.Options{
    HostPort:  container.HostPort(),
    Namespace: "default",
})

Configuration options:

testcontainer.Options{
    Image:           "temporalio/temporal:latest", // Docker image
    StartupTimeout:  60 * time.Second,             // Startup timeout
    Logger:          t,                            // *testing.T or custom logger
    ExtraPorts:      []string{"8080/tcp"},         // Additional ports
    InitialWaitTime: 3 * time.Second,              // Wait after startup
}

See the testcontainer package documentation and examples for more details.

Contributing

When adding new integration tests:

  1. Use the //go:build integration tag.
  2. Create unique identifiers (workflow IDs, task queues, schedule IDs — timestamps work well).
  3. Use the testcontainer package (testcontainer.Setup()).
  4. Construct clients with temporal.NewClient(...) and managers with the typed constructors (NewWorkerManager(c), etc.).
  5. Document any new configuration requirements.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(opts ...Option) (client.Client, error)

NewClient creates a Temporal client. It starts from DefaultConfig and applies the given options in order.

Example

ExampleNewClient demonstrates creating a Temporal client with the options API. Without options, NewClient dials localhost:7233 in the "default" namespace. The caller owns the returned client and must close it.

This example has no Output comment because the result depends on a running Temporal server; it is compile-checked but not executed by go test.

package main

import (
	"fmt"

	"github.com/jasoet/pkg/v3/temporal"
)

func main() {
	c, err := temporal.NewClient(
		temporal.WithHostPort("localhost:7233"),
		temporal.WithNamespace("default"),
	)
	if err != nil {
		// No Temporal server is listening; handle the dial error.
		fmt.Println("dial failed:", err != nil)
		return
	}
	defer c.Close()

	fmt.Println("connected:", c != nil)
}

Types

type Config

type Config struct {
	HostPort   string       `yaml:"hostPort" mapstructure:"hostPort"`
	Namespace  string       `yaml:"namespace" mapstructure:"namespace"`
	OTelConfig *otel.Config `yaml:"-" mapstructure:"-"`

	// TLS configures a TLS connection to the Temporal frontend. Required for
	// Temporal Cloud and any TLS-enabled self-hosted server. Not serializable.
	TLS *tls.Config `yaml:"-" mapstructure:"-"`

	// Credentials authenticates the client — e.g. an API key for Temporal
	// Cloud (client.NewAPIKeyStaticCredentials) or mTLS. Not serializable.
	Credentials client.Credentials `yaml:"-" mapstructure:"-"`
	// contains filtered or unexported fields
}

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a Config with sensible defaults. It is a pure factory function and performs no I/O or logging.

type DashboardStats

type DashboardStats struct {
	TotalRunning    int64
	TotalCompleted  int64
	TotalFailed     int64
	TotalCanceled   int64
	TotalTerminated int64
	AverageDuration time.Duration
}

DashboardStats provides aggregated workflow statistics

type Option

type Option func(*Config)

Option mutates a Config. Options are applied to DefaultConfig by NewClient.

func WithClientOptions

func WithClientOptions(fn func(*client.Options)) Option

WithClientOptions registers a hook that receives the fully-assembled client.Options immediately before dialing, letting callers set any SDK option this package does not expose directly. Hooks run in registration order, last, so they can override everything set beforehand.

func WithConfig

func WithConfig(c Config) Option

WithConfig replaces the entire configuration with c.

func WithCredentials

func WithCredentials(creds client.Credentials) Option

WithCredentials sets the client credentials used to authenticate — for example an API key for Temporal Cloud via client.NewAPIKeyStaticCredentials, or mTLS credentials.

func WithHostPort

func WithHostPort(addr string) Option

WithHostPort sets the Temporal frontend address (host:port).

func WithNamespace

func WithNamespace(ns string) Option

WithNamespace sets the Temporal namespace.

func WithOTelConfig

func WithOTelConfig(otelCfg *otel.Config) Option

WithOTelConfig attaches OTel tracing/metrics to the client.

func WithTLS

func WithTLS(tlsCfg *tls.Config) Option

WithTLS enables a TLS connection to the Temporal frontend using tlsCfg. Required for Temporal Cloud and TLS-enabled self-hosted servers.

type ScheduleManager

type ScheduleManager struct {
	// contains filtered or unexported fields
}

func NewScheduleManager

func NewScheduleManager(temporalClient client.Client) (*ScheduleManager, error)

NewScheduleManager creates a ScheduleManager using the provided client. The caller retains ownership of the client and is responsible for closing it; Close does not close the client.

Example

ExampleNewScheduleManager demonstrates creating a ScheduleManager from a caller-owned client. ScheduleManager.Close(ctx) does not close the client; the caller closes it.

This example has no Output comment because the result depends on a running Temporal server; it is compile-checked but not executed by go test.

package main

import (
	"context"
	"fmt"
	"time"

	"github.com/jasoet/pkg/v3/temporal"
)

func main() {
	ctx := context.Background()

	c, err := temporal.NewClient()
	if err != nil {
		fmt.Println("dial failed:", err != nil)
		return
	}
	defer c.Close()

	sm, err := temporal.NewScheduleManager(c)
	if err != nil {
		fmt.Println("manager failed:", err != nil)
		return
	}
	defer sm.Close(ctx)

	// Create an interval schedule (requires a running Temporal server).
	_, err = sm.CreateWorkflowSchedule(ctx, "hourly-report", temporal.WorkflowScheduleOptions{
		WorkflowID: "report-workflow",
		Workflow:   "ReportWorkflow", // or a workflow function reference
		TaskQueue:  "reports",
		Interval:   time.Hour,
		Args:       []any{"daily-report"},
	})
	if err != nil {
		fmt.Println("schedule failed:", err != nil)
		return
	}

	fmt.Println("schedule created")
}

func (*ScheduleManager) Close

func (sm *ScheduleManager) Close(ctx context.Context)

Close closes the ScheduleManager. It does not close the Temporal client; the caller owns the client and must close it. The ctx parameter is used for logging only.

func (*ScheduleManager) CreateSchedule

func (sm *ScheduleManager) CreateSchedule(ctx context.Context, scheduleID string, spec client.ScheduleSpec, action *client.ScheduleWorkflowAction) (client.ScheduleHandle, error)

func (*ScheduleManager) CreateScheduleWithOptions

func (sm *ScheduleManager) CreateScheduleWithOptions(ctx context.Context, options client.ScheduleOptions) (client.ScheduleHandle, error)

func (*ScheduleManager) CreateWorkflowSchedule

func (sm *ScheduleManager) CreateWorkflowSchedule(ctx context.Context, scheduleName string, options WorkflowScheduleOptions) (client.ScheduleHandle, error)

func (*ScheduleManager) DeleteSchedule

func (sm *ScheduleManager) DeleteSchedule(ctx context.Context, scheduleID string) error

DeleteSchedule deletes a specific schedule by ID

func (*ScheduleManager) DeleteSchedules

func (sm *ScheduleManager) DeleteSchedules(ctx context.Context) error

DeleteSchedules deletes every schedule this manager is tracking. It is convergent under partial failure: each schedule is deleted independently, a NotFound response is treated as success (the schedule is already gone), and every successfully-removed schedule is dropped from tracking so a retry converges instead of re-deleting or re-hitting NotFound. Schedules whose deletion genuinely failed are left in tracking and their errors are joined and returned. RPCs are made without holding the manager lock.

func (*ScheduleManager) GetClient

func (sm *ScheduleManager) GetClient() client.Client

func (*ScheduleManager) GetSchedule

func (sm *ScheduleManager) GetSchedule(ctx context.Context, scheduleID string) (client.ScheduleHandle, error)

GetSchedule retrieves a schedule handle by ID

func (*ScheduleManager) GetScheduleHandlers

func (sm *ScheduleManager) GetScheduleHandlers() map[string]client.ScheduleHandle

func (*ScheduleManager) ListSchedules

func (sm *ScheduleManager) ListSchedules(ctx context.Context, limit int) ([]*client.ScheduleListEntry, error)

ListSchedules lists all schedules with a limit

func (*ScheduleManager) UpdateSchedule

func (sm *ScheduleManager) UpdateSchedule(ctx context.Context, scheduleID string, spec client.ScheduleSpec, action *client.ScheduleWorkflowAction) error

UpdateSchedule updates an existing schedule

type WorkerManager

type WorkerManager struct {
	// contains filtered or unexported fields
}

func NewWorkerManager

func NewWorkerManager(client client.Client) (*WorkerManager, error)

NewWorkerManager creates a WorkerManager using the provided client. The caller retains ownership of the client and is responsible for closing it; Close does not close the client.

func (*WorkerManager) Close

func (wm *WorkerManager) Close(ctx context.Context)

Close stops all registered workers. It does not close the Temporal client; the caller owns the client and must close it. The ctx parameter is used for logging only. Close is idempotent and safe to call concurrently: the underlying workers are stopped at most once, avoiding the double-close panic that the SDK's worker.Stop() raises on a second invocation.

func (*WorkerManager) GetClient

func (wm *WorkerManager) GetClient() client.Client

GetClient returns the Temporal client provided at construction. The client is owned by the caller; Close does not close it.

func (*WorkerManager) GetWorkers

func (wm *WorkerManager) GetWorkers() []worker.Worker

func (*WorkerManager) Register

func (wm *WorkerManager) Register(taskQueue string, options worker.Options) worker.Worker

func (*WorkerManager) Start

func (wm *WorkerManager) Start(ctx context.Context, w worker.Worker) error

Start starts the given worker. The ctx parameter is used for logging only; the worker's internal lifecycle is managed by the Temporal SDK.

func (*WorkerManager) StartAll

func (wm *WorkerManager) StartAll(ctx context.Context) error

type WorkflowDetails

type WorkflowDetails struct {
	WorkflowID    string
	RunID         string
	WorkflowType  string
	Status        enums.WorkflowExecutionStatus
	StartTime     time.Time
	CloseTime     time.Time
	ExecutionTime time.Duration
	HistoryLength int64
}

WorkflowDetails contains detailed information about a workflow execution

type WorkflowManager

type WorkflowManager struct {
	// contains filtered or unexported fields
}

WorkflowManager provides workflow query and management operations.

All operations resolve their namespace consistently: an empty namespace (the default from NewWorkflowManager) means "use the namespace the client was configured with", matching the client-method calls (Describe/Cancel/ Signal/Query/GetResult) which always target the client's namespace. Supply an explicit namespace via NewWorkflowManagerWithNamespace only to scope the visibility queries (List/Count) to a different namespace.

func NewWorkflowManager

func NewWorkflowManager(client client.Client) (*WorkflowManager, error)

NewWorkflowManager creates a new WorkflowManager that inherits the namespace the client was configured with, so every operation agrees on the namespace. Use NewWorkflowManagerWithNamespace to scope visibility queries to a different namespace. The caller retains ownership of the client and is responsible for closing it.

func NewWorkflowManagerWithNamespace

func NewWorkflowManagerWithNamespace(client client.Client, namespace string) (*WorkflowManager, error)

NewWorkflowManagerWithNamespace creates a new WorkflowManager that scopes its List/Count visibility queries to the given namespace. Pass "" to inherit the client's configured namespace (equivalent to NewWorkflowManager). Supplying a namespace that differs from the client's affects only List/Count; the other operations always target the client's namespace. The caller retains ownership of the client and is responsible for closing it.

func (*WorkflowManager) CancelWorkflow

func (wm *WorkflowManager) CancelWorkflow(ctx context.Context, workflowID, runID string) error

CancelWorkflow cancels a running workflow execution

func (*WorkflowManager) CountWorkflows

func (wm *WorkflowManager) CountWorkflows(ctx context.Context, query string) (int64, error)

CountWorkflows counts workflows matching a query

func (*WorkflowManager) DescribeWorkflow

func (wm *WorkflowManager) DescribeWorkflow(ctx context.Context, workflowID, runID string) (*WorkflowDetails, error)

DescribeWorkflow retrieves detailed information about a specific workflow execution

func (*WorkflowManager) GetClient

func (wm *WorkflowManager) GetClient() client.Client

GetClient returns the Temporal client provided at construction. The client is owned by the caller and must be closed by the caller.

func (*WorkflowManager) GetDashboardStats

func (wm *WorkflowManager) GetDashboardStats(ctx context.Context) (*DashboardStats, error)

GetDashboardStats retrieves aggregated statistics for all workflows

func (*WorkflowManager) GetRecentWorkflows

func (wm *WorkflowManager) GetRecentWorkflows(ctx context.Context, limit int) ([]*WorkflowDetails, error)

GetRecentWorkflows retrieves the most recent workflow executions

func (*WorkflowManager) GetWorkflowHistory

func (wm *WorkflowManager) GetWorkflowHistory(ctx context.Context, workflowID, runID string) (*workflowservice.GetWorkflowExecutionHistoryResponse, error)

GetWorkflowHistory retrieves the full event history of a workflow execution. It queries the client's configured namespace (the manager's explicit namespace override, if any, applies only to List/Count visibility queries). All pages are collected into the returned response's History.Events.

func (*WorkflowManager) GetWorkflowResult

func (wm *WorkflowManager) GetWorkflowResult(ctx context.Context, workflowID, runID string, valuePtr any) error

GetWorkflowResult retrieves the result of a workflow run into valuePtr.

This BLOCKS until the run completes: run.Get waits for a still-running workflow to finish rather than returning immediately. For dashboard-style callers that must not hang on a running workflow, gate this behind a GetWorkflowStatus check for a terminal status, or pass a ctx with a deadline.

func (*WorkflowManager) GetWorkflowStatus

func (wm *WorkflowManager) GetWorkflowStatus(ctx context.Context, workflowID, runID string) (enums.WorkflowExecutionStatus, error)

GetWorkflowStatus returns the current status of a workflow execution

func (*WorkflowManager) ListCompletedWorkflows

func (wm *WorkflowManager) ListCompletedWorkflows(ctx context.Context, pageSize int) ([]*WorkflowDetails, error)

ListCompletedWorkflows returns completed workflows

func (*WorkflowManager) ListFailedWorkflows

func (wm *WorkflowManager) ListFailedWorkflows(ctx context.Context, pageSize int) ([]*WorkflowDetails, error)

ListFailedWorkflows returns failed workflows

func (*WorkflowManager) ListRunningWorkflows

func (wm *WorkflowManager) ListRunningWorkflows(ctx context.Context, pageSize int) ([]*WorkflowDetails, error)

ListRunningWorkflows returns all currently running workflows

func (*WorkflowManager) ListWorkflows

func (wm *WorkflowManager) ListWorkflows(ctx context.Context, pageSize int, query string) ([]*WorkflowDetails, error)

ListWorkflows lists workflows with pagination and optional query filter

func (*WorkflowManager) ListWorkflowsByStatus

func (wm *WorkflowManager) ListWorkflowsByStatus(ctx context.Context, status enums.WorkflowExecutionStatus, pageSize int) ([]*WorkflowDetails, error)

ListWorkflowsByStatus lists workflows filtered by execution status

func (*WorkflowManager) QueryWorkflow

func (wm *WorkflowManager) QueryWorkflow(ctx context.Context, workflowID, runID, queryType string, args ...any) (any, error)

QueryWorkflow queries a running workflow for custom data. The returned value is the SDK's raw converter.EncodedValue (not the decoded payload); type-assert it to converter.EncodedValue and call Get(&dst) to decode into a typed value.

func (*WorkflowManager) SearchWorkflowsByID

func (wm *WorkflowManager) SearchWorkflowsByID(ctx context.Context, workflowIDPrefix string, pageSize int) ([]*WorkflowDetails, error)

SearchWorkflowsByID searches for workflows matching a workflow ID pattern

func (*WorkflowManager) SearchWorkflowsByType

func (wm *WorkflowManager) SearchWorkflowsByType(ctx context.Context, workflowType string, pageSize int) ([]*WorkflowDetails, error)

SearchWorkflowsByType searches workflows by workflow type name

func (*WorkflowManager) SignalWorkflow

func (wm *WorkflowManager) SignalWorkflow(ctx context.Context, workflowID, runID, signalName string, arg any) error

SignalWorkflow sends a signal to a running workflow

func (*WorkflowManager) TerminateWorkflow

func (wm *WorkflowManager) TerminateWorkflow(ctx context.Context, workflowID, runID, reason string) error

TerminateWorkflow terminates a workflow execution with a reason

type WorkflowScheduleOptions

type WorkflowScheduleOptions struct {
	WorkflowID string
	Workflow   any
	TaskQueue  string
	Interval   time.Duration
	Args       []any
}

type ZerologAdapter

type ZerologAdapter struct {
	// contains filtered or unexported fields
}

func NewZerologAdapter

func NewZerologAdapter(logger zerolog.Logger) *ZerologAdapter

NewZerologAdapter creates a new ZerologAdapter

func (*ZerologAdapter) Debug

func (z *ZerologAdapter) Debug(msg string, keyvals ...any)

func (*ZerologAdapter) Error

func (z *ZerologAdapter) Error(msg string, keyvals ...any)

func (*ZerologAdapter) Info

func (z *ZerologAdapter) Info(msg string, keyvals ...any)

func (*ZerologAdapter) Warn

func (z *ZerologAdapter) Warn(msg string, keyvals ...any)

func (*ZerologAdapter) With

func (z *ZerologAdapter) With(keyvals ...any) temporallog.Logger

func (*ZerologAdapter) WithCallerSkip

func (z *ZerologAdapter) WithCallerSkip(skip int) temporallog.Logger

Directories

Path Synopsis
Package job provides a type-focused abstraction for one registered Temporal workflow.
Package job provides a type-focused abstraction for one registered Temporal workflow.
Package testcontainer provides utilities for running Temporal server in Docker containers for integration testing.
Package testcontainer provides utilities for running Temporal server in Docker containers for integration testing.

Jump to

Keyboard shortcuts

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