temporal

package
v0.5.2 Latest Latest
Warning

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

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

Documentation

Overview

Package temporal is the client side of the Temporal runtime: Client implements session.Client with one Temporal workflow per session. It starts, signals and queries those workflows and reads their event streams; a worker from package session/temporal/worker runs them. This package imports no worker code, so a host that only talks to sessions does not build the harness.

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 that ignores DNS-provided gRPC service configs and, unless opts has a metrics handler of its own, reports the Temporal SDK's metrics (workflow task and activity latencies, poll counts, failures) to the process-wide MeterProvider: set it up (export.Init) before Dial. A worker built from the client reports them too.

A turn's trace needs nothing from Temporal: the wake that starts it and each step carry the trace's context themselves, so the plugin's header propagation and its own spans are not needed.

Types

type Client added in v0.5.0

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

Client implements session.Client with one Temporal workflow per session.

func Open

func Open(c client.Client, cfg Config) *Client

Open returns a Client over c. It panics without c, Store or Secrets.

func (*Client) Cancel added in v0.5.0

func (r *Client) Cancel(ctx context.Context, sessionID session.ID) error

Cancel implements session.Client.

func (*Client) Close added in v0.5.0

func (r *Client) Close(ctx context.Context, sessionID session.ID) error

Close implements session.Client. The session's workflow deletes what its harness saved (its messages in the brain) as it closes; Close deletes the session's credentials, its jobs' credentials, its record and its log. Every step runs even when an earlier one fails, and the failures are returned together. A part already gone (session.ErrNotFound) is not a failure, so Close is safe to repeat.

func (*Client) CreateSession added in v0.5.0

func (r *Client) CreateSession(ctx context.Context, req session.CreateSession) (session.ID, error)

CreateSession implements session.Client. A worker name no worker registered fails the session when it runs.

func (*Client) Head added in v0.5.0

func (r *Client) Head(ctx context.Context, sessionID session.ID) (session.Seq, error)

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

func (*Client) Jobs added in v0.5.0

func (r *Client) Jobs(ctx context.Context, parent session.ID) ([]session.Status, error)

Jobs implements session.Client.

func (*Client) Prompt added in v0.5.0

func (r *Client) Prompt(ctx context.Context, sessionID session.ID, msg session.Prompt) error

Prompt implements session.Client.

func (*Client) Resume added in v0.5.0

func (r *Client) Resume(ctx context.Context, sessionID session.ID, resume session.Resume) error

Resume implements session.Client.

func (*Client) Status added in v0.5.0

func (r *Client) Status(ctx context.Context, id session.ID) (session.Status, error)

Status implements session.Client.

func (*Client) Subscribe added in v0.5.0

func (r *Client) Subscribe(ctx context.Context, sessionID session.ID, after session.Seq) (session.Subscription, error)

Subscribe implements session.Client: the session's durable events, from its stream or the fallback log, with its deltas from the live endpoint of the worker that holds its harness between them.

type Config

type Config struct {
	// TaskQueue is the queue the session workflows start on. Zero is
	// "tacklr".
	TaskQueue string
	// Store is the session record the workers save; Close deletes it. It
	// is required. Tokens never go here.
	Store session.Store
	// Secrets holds work-item credentials: Prompt and Resume write them,
	// Close deletes them. It is required. Tokens never enter event history.
	Secrets session.SecretStorage
	// Fallback is the EventLog Subscribe reads when DisableStreams is set,
	// and Head reads when the stream does not answer. Zero is an in-memory
	// log, which reaches no worker.
	Fallback session.EventLog
	// DisableStreams uses the fallback EventLog instead of Workflow Streams.
	DisableStreams bool
	// Live is how Subscribe reaches the live endpoint of the worker that
	// holds a session's harness, for its deltas. A zero Live gets whole
	// messages only.
	Live Live
	// WorkerQueueTimeout is how long a step waits to start on the worker
	// that holds its session's harness. A step that did not start in time
	// (that worker is gone) goes to another worker, which builds the harness
	// again. Zero is 10 seconds.
	WorkerQueueTimeout 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 for a wrapped network
	// error, a model refusal, or a stale checkpoint. Zero is 3. 1 means no
	// retry. Any other activity error stops on the first attempt.
	ActivityAttempts int32
	// MaxConcurrentToolCalls is how many Tool steps of one reply run at
	// once; the rest start as those finish. Zero is 32.
	MaxConcurrentToolCalls int
	// MaxChildren is how many children (specialists and jobs) a session
	// runs at once; a start past it is a correction for the model. Zero is
	// 1,000, under Temporal's default limit of 2,000.
	MaxChildren int
	// ContinueAsNewEvents, when > 0, continues a session as new once its
	// history reaches that many events, at an idle point. Zero follows
	// Temporal's own suggestion (GetContinueAsNewSuggested).
	ContinueAsNewEvents int
}

Config is the host config for Open. Store, Secrets, Fallback, DisableStreams and TaskQueue name what the workers use too: give a worker's Config the same ones.

type Live added in v0.5.0

type Live struct {
	// Key is the HMAC key the workers have. A zero Key dials no worker.
	Key []byte
	// HTTP is the client that dials them; zero is http.DefaultClient.
	HTTP *http.Client
}

Live is how a Client reaches the live endpoints of the workers (worker.Config.Live), where the deltas of their model calls stream. Deltas are never stored, so Subscribe dials the worker that holds the session's harness.

Directories

Path Synopsis
internal
protocol
Package protocol is how a Temporal client and worker talk about one session: the workflow's type name and input, its signal and query names, and the item its event stream carries.
Package protocol is how a Temporal client and worker talk about one session: the workflow's type name and input, its signal and query names, and the item its event stream carries.
Package worker runs tacklr sessions on Temporal: it registers the session workflow and its turn activities, and keeps each session's harness (VFS, MCP connections, tools) between steps.
Package worker runs tacklr sessions on Temporal: it registers the session workflow and its turn activities, and keeps each session's harness (VFS, MCP connections, tools) between steps.

Jump to

Keyboard shortcuts

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