temporal

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package temporal is the Temporal adapter for durable.Runtime. Hosts use Dial, New, and NewWorker with the same Config (including Snapshots and Secrets). NewWorker registers SessionWorkflow and the turn activities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(opts client.Options) (client.Client, error)

Dial is client.Dial with Temporal's OpenTelemetry v2 plugin prepended. Call telemetry.Init first so the global TracerProvider is ReplaySafe; NewPlugin reads otel.GetTracerProvider() and otel.GetMeterProvider(). Default: context propagation only (no SDK auto-spans). SessionWorkflow starts tacklr.turn via temporalotel.Tracer.

func NewWorker

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

NewWorker returns a Temporal worker with EnableSessionWorker and SessionWorkflow plus Inference, Tool, CommitToolOutput, and EmitEvent activities. Pass the same Config as New, including Snapshots and Secrets. Worker sessions exist only when Config.TurnLocality > 0.

func SessionWorkflow

func SessionWorkflow(ctx workflow.Context, in workflowInput) (string, error)

SessionWorkflow is the Temporal type name for the session wait loop. NewWorker registers it. Hosts call durable.Runtime, not this function.

Types

type Config added in v0.2.1

type Config struct {
	Catalog   durable.Catalog
	TaskQueue string
	// Snapshots is the session record. Required. New and NewWorker must share
	// the same instance. Tokens never go here.
	Snapshots  durable.SnapshotStore
	Fallback   durable.EventLog
	Projection vfs.Projection
	// DisableStreams uses the fallback EventLog instead of Workflow Streams.
	// Tests that use the Temporal testsuite mock must set this.
	DisableStreams bool
	// TurnLocality, when > 0, pins a turn's activities to one worker.
	TurnLocality time.Duration
	// ActivityTimeout is Inference/Tool StartToCloseTimeout. Zero is 10 minutes.
	ActivityTimeout time.Duration
	// HeartbeatTimeout is the activity heartbeat timeout. Zero is 30 seconds.
	HeartbeatTimeout time.Duration
	// ActivityAttempts is Temporal MaximumAttempts. Zero is 3. 1 means no retry.
	ActivityAttempts int32
	// Secrets holds work-item credentials for activities. Required. New and
	// NewWorker must share the same instance. Tokens never enter event history.
	Secrets durable.SecretStorage
}

Config is the single Temporal host config for New and NewWorker.

type Runtime

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

Runtime implements durable.Runtime with one Temporal workflow per session.

func New

func New(c client.Client, cfg Config) *Runtime

New constructs a Temporal Runtime. The host must also run NewWorker on the same Config, including the same Snapshots and Secrets stores.

func (*Runtime) Cancel

func (r *Runtime) Cancel(ctx context.Context, sessionID durable.SessionID) error

Cancel implements durable.Runtime.

func (*Runtime) Children

func (r *Runtime) Children(ctx context.Context, parent durable.SessionID) ([]durable.SessionID, error)

Children implements durable.Runtime.

func (*Runtime) Close

func (r *Runtime) Close(ctx context.Context, sessionID durable.SessionID) error

Close implements durable.Runtime.

func (*Runtime) CreateSession

func (r *Runtime) CreateSession(ctx context.Context, req durable.CreateSession) (durable.SessionID, error)

CreateSession implements durable.Runtime.

func (*Runtime) Head

func (r *Runtime) Head(ctx context.Context, sessionID durable.SessionID) (durable.Seq, error)

Head implements durable.Runtime. When Workflow Streams is on, this is the stream's next offset so Subscribe(after Head) skips prior-turn events.

func (*Runtime) Prompt

func (r *Runtime) Prompt(ctx context.Context, sessionID durable.SessionID, msg durable.Prompt) error

func (*Runtime) Resume

func (r *Runtime) Resume(ctx context.Context, sessionID durable.SessionID, resume durable.Resume) error

func (*Runtime) Status

Status implements durable.Runtime.

func (*Runtime) Subscribe

func (r *Runtime) Subscribe(ctx context.Context, sessionID durable.SessionID, after durable.Seq) (durable.Subscription, error)

Subscribe implements durable.Runtime.

Jump to

Keyboard shortcuts

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