temporal

package
v0.6.81 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package temporal is a Temporal client as a dependency: a configuration section, a client traced and measured through the service's OpenTelemetry providers and logging through its logger, a health probe. The SDK's own connection (BACKPLANE_TEMPORAL_*: hooks, activities, workflows) dials through Options too.

For a Temporal of the service's own — another cluster or namespace:

type Config struct {
    config.Backplane `json:"backplane"`
    Billing temporal.Config `json:"billing"` // SHOP_BILLING_ADDR, _NS, ...
}

billing := deps.NewDependency(root, temporal.New(cfg.Billing), deps.Name("billing"))
run, err := billing.Get().ExecuteWorkflow(ctx, opts, "Charge", in)

Index

Constants

View Source
const (
	DefaultNamespace   = "default"
	DefaultDialTimeout = 2 * time.Second
)

Defaults of Config.

View Source
const EncodingSealed = "binary/backplane-sealed"

EncodingSealed marks a payload the codec sealed: its data is the original payload, sealed.

Variables

View Source
var ErrNoAddr = errors.New("temporal: addr is required")

ErrNoAddr: the section has no address.

View Source
var ErrUnsealed = errors.New("temporal: payload is not sealed and encryption is required")

ErrUnsealed: a strict codec got a payload it did not seal.

View Source
var Plain = Codec{} //nolint:gochecknoglobals // a constant value

Plain is the codec of an installation without encryption.

Functions

func New

func New(cfg Config) deps.Provider[Client]

New is the provider of the client: Provide dials, the probe checks the frontend's health, Close closes.

func Options

func Options(cfg Config, identity string, log *xlog.Logger) (client.Options, error)

Options are the client options of cfg: address, namespace, TLS, API key, identity, the logger, OpenTelemetry tracing and metrics.

Types

type Client

type Client = client.Client

Client is the Temporal SDK's client.

func Dial

func Dial(ctx context.Context, cfg Config, opts client.Options) (Client, error)

Dial makes one connection attempt bounded by the dial timeout.

type Codec added in v0.6.51

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

Codec seals every payload whole, metadata included, and opens what it sealed; a payload it did not seal passes as it is, so history written before encryption was on stays readable. Plain is the codec that changes nothing.

func NewCodec added in v0.6.51

func NewCodec(cfg config.Seal) (Codec, error)

NewCodec is the codec of an encryption section (config.Temporal).

func (Codec) Decode added in v0.6.51

func (c Codec) Decode(payloads []*commonpb.Payload) ([]*commonpb.Payload, error)

Decode implements converter.PayloadCodec (the Temporal SDK gives it no context). A strict codec refuses what it did not seal.

func (Codec) DecodeContext added in v0.6.51

func (c Codec) DecodeContext(ctx context.Context, payloads []*commonpb.Payload) ([]*commonpb.Payload, error)

DecodeContext opens what the codec sealed, Vault calls bound by ctx.

func (Codec) DecodeMessage added in v0.6.51

func (c Codec) DecodeMessage(ctx context.Context, m proto.Message) error

DecodeMessage decodes, in place, every payload m holds, however deep: a history event, a describe or list response read through the raw service API. Without encryption it changes nothing.

func (Codec) DecodeOne added in v0.6.51

func (c Codec) DecodeOne(ctx context.Context, p *commonpb.Payload) (*commonpb.Payload, error)

DecodeOne is DecodeContext of one payload, which is not nil.

func (Codec) Encode added in v0.6.51

func (c Codec) Encode(payloads []*commonpb.Payload) ([]*commonpb.Payload, error)

Encode implements converter.PayloadCodec (the Temporal SDK gives it no context).

func (Codec) EncodeContext added in v0.6.51

func (c Codec) EncodeContext(ctx context.Context, payloads []*commonpb.Payload) ([]*commonpb.Payload, error)

EncodeContext seals payloads, Vault calls bound by ctx.

func (Codec) Sealer added in v0.6.51

func (c Codec) Sealer() seal.Sealer

Sealer is the codec's sealer; nil without encryption.

func (Codec) Strict added in v0.6.52

func (c Codec) Strict(on bool) Codec

Strict is the codec refusing, in Decode, payloads it did not seal: once no run from before encryption is left, nothing unsealed is taken. The console's DecodeMessage stays lenient: Temporal keeps memos and search attributes unsealed.

type Config

type Config struct {
	// Addr is the frontend's host:port.
	Addr      string     `desc:"Frontend host:port."    json:"addr,omitempty"`
	Namespace string     `desc:"Temporal namespace."    json:"ns"             schemapb:"default=default"`
	TLS       config.TLS `desc:"TLS of the connection." json:"tls"`
	// APIKey authenticates to Temporal Cloud; it turns TLS on even when TLS
	// is not enabled.
	APIKey config.Secret `desc:"Temporal Cloud API key; turns TLS on." json:"api_key,omitempty"`
	// DialTimeout bounds one connection attempt.
	DialTimeout time.Duration `desc:"Bound of one connection attempt." json:"dial_timeout" schemapb:"default=2s"`
	// Encryption of the payloads in workflow history; empty: off.
	Encryption config.Seal `desc:"Encrypts payloads in workflow history; empty: off." json:"encryption"`
	// RequireEncryption refuses payloads that are not sealed.
	RequireEncryption bool `desc:"Refuse workflow payloads that are not sealed." json:"require_encryption" schemapb:"default=false"`
}

Config is the connection's section. Field `ns`: `namespace` is a CEL reserved word.

func (Config) Enabled

func (c Config) Enabled() bool

Enabled reports whether an address is set.

func (Config) Validate

func (c Config) Validate() error

Validate checks what the schema cannot: the address is set and the TLS material parses.

func (Config) WithDefaults

func (c Config) WithDefaults() Config

WithDefaults fills a zero namespace and dial timeout.

Jump to

Keyboard shortcuts

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