temporal

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const MemoWorkflowName = "TrajectoryIRMemoWorkflow"

MemoWorkflowName is the registered workflow type for step memo storage.

Variables

This section is empty.

Functions

func MemoWorkflow

func MemoWorkflow(ctx workflow.Context, value []byte) ([]byte, error)

MemoWorkflow stores a step result as the workflow return value. Workflow id is MemoWorkflowID(workflowID, stepKey). Reusing the same id after completion is rejected so the first Save wins (Load returns that result).

func MemoWorkflowID

func MemoWorkflowID(workflowID, stepKey string) string

MemoWorkflowID builds a stable Temporal workflow id for one durable step memo.

func NewWorker

func NewWorker(c client.Client, cfg Config) (worker.Worker, error)

NewWorker registers memo workflows on the configured task queue. The process must call Run (or Run with interrupt) to process tasks.

Types

type Backend

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

Backend implements durable.Backend using Temporal workflows as durable memos.

Each (workflowID, stepKey) maps to one Temporal workflow whose result is the JSON step payload. The first Save starts that workflow; later Saves are no-ops when the workflow already exists. Load returns the completed workflow result.

A worker registered via NewWorker must be running for Save to complete. This matches LocalSQLite semantics: Infer/Tool still execute fn in-process, then persist the result through the Backend. Moving fn into activities is a later hardening step.

func Dial

func Dial(ctx context.Context, cfg Config) (*Backend, error)

Dial connects to Temporal and returns a Backend.

func NewBackend

func NewBackend(c client.Client, taskQueue string) (*Backend, error)

NewBackend wraps an existing Temporal client.

func (*Backend) Close

func (b *Backend) Close() error

Close implements durable.Backend.

func (*Backend) Load

func (b *Backend) Load(ctx context.Context, workflowID, stepKey string) ([]byte, bool, error)

Load implements durable.Backend.

func (*Backend) Save

func (b *Backend) Save(ctx context.Context, workflowID, stepKey string, value []byte) error

Save implements durable.Backend. First successful start wins.

type Config

type Config struct {
	HostPort  string // e.g. localhost:7233
	Namespace string // e.g. default
	TaskQueue string // e.g. trajectory-ir
	// TLS enables TLS on the Temporal frontend connection.
	TLS bool
	// APIKey is an optional Temporal Cloud API key (requires TLS).
	APIKey string
}

Config holds Temporal client and worker settings. Env defaults match a local Temporal dev server (plaintext). For production, set TEMPORAL_TLS=true and optionally TEMPORAL_API_KEY.

func ConfigFromEnv

func ConfigFromEnv() Config

ConfigFromEnv reads TEMPORAL_HOSTPORT, TEMPORAL_NAMESPACE, TEMPORAL_TASK_QUEUE, TEMPORAL_TLS, and TEMPORAL_API_KEY.

func (Config) ClientOptions

func (c Config) ClientOptions() client.Options

ClientOptions builds SDK client options from this config. Local defaults remain plaintext; production should enable TLS.

func (Config) Validate

func (c Config) Validate() error

Validate checks required fields and TLS/API key consistency.

Jump to

Keyboard shortcuts

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