Documentation
¶
Overview ¶
Package temporalpayload provides the local, size-aware Temporal payload codec chain.
A Codec always starts with Temporal's normal serialization. It retains that representation unless a zstd wrapper is strictly smaller, then retains that representation unless an immutable content-addressed blob reference is strictly smaller. Runtime clients and workers use Codec.DataConverter locally. NewUIHandler exposes the identical codec only for an authorized Temporal UI inspection endpoint; it is never on a worker's normal path.
The package provides integrity and compatibility, not encryption. Callers provide the BlobStore implementation appropriate to their object store and must declare its endpoint, credentials, prefix, lifecycle, and retention in their deployment configuration.
Index ¶
- Constants
- Variables
- func NewUIHandler(codec *Codec, options ...UIHandlerOption) (http.Handler, error)
- type AuthorizationDecision
- type BlobKey
- type BlobObject
- type BlobStore
- type Codec
- type GarbageCollector
- type MemoryBlobStore
- func (store *MemoryBlobStore) Count() int
- func (store *MemoryBlobStore) Delete(ctx context.Context, key BlobKey) error
- func (store *MemoryBlobStore) Get(ctx context.Context, key BlobKey, maxBytes int) ([]byte, error)
- func (store *MemoryBlobStore) Put(ctx context.Context, key BlobKey, value []byte) error
- type Observation
- type Observer
- type Option
- type RetentionCoordinator
- type UIHandlerOption
- type UIRequestAuthorizer
- type UIRequestAuthorizerFunc
Constants ¶
const ( // EncodingZstd identifies a v1 zstd-wrapped Temporal payload. EncodingZstd = "binary/zstd" // EncodingRemote identifies a v1 immutable blob-reference Temporal payload. EncodingRemote = "binary/remote-payload" )
Variables ¶
var ( // ErrUnsupportedVersion reports a payload written by a codec version outside the declared compatibility window. ErrUnsupportedVersion = errors.New("unsupported temporal payload codec version") // ErrInvalidPayload reports malformed codec metadata, references, or nested payload bytes. ErrInvalidPayload = errors.New("invalid temporal payload codec payload") )
var ( // ErrBlobNotFound reports a payload reference whose immutable content is absent. ErrBlobNotFound = errors.New("temporal payload blob not found") // ErrBlobIntegrity reports a payload reference whose content does not match its digest or size. ErrBlobIntegrity = errors.New("temporal payload blob integrity check failed") // ErrBlobTooLarge reports a blob which exceeds the codec's configured finite bound. ErrBlobTooLarge = errors.New("temporal payload blob exceeds configured size limit") )
Functions ¶
func NewUIHandler ¶
func NewUIHandler(codec *Codec, options ...UIHandlerOption) (http.Handler, error)
NewUIHandler creates the authenticated HTTP adapter used only by Temporal UI inspection.
Types ¶
type AuthorizationDecision ¶
AuthorizationDecision reports the result of an authentication and namespace-authorization check.
It deliberately contains no credential, header, token, or principal value so the payload package has nothing sensitive to log or retain.
type BlobKey ¶
type BlobKey string
BlobKey identifies an immutable object owned by the payload codec.
Codec creates keys from a configured prefix and the SHA-256 digest of stored bytes. BlobStore implementations must treat a key as opaque and must not infer an object-store endpoint from it.
type BlobObject ¶
BlobObject is immutable blob metadata exposed only to an explicit retention worker.
type BlobStore ¶
type BlobStore interface {
Put(context.Context, BlobKey, []byte) error
Get(context.Context, BlobKey, int) ([]byte, error)
}
BlobStore stores immutable payload content under a codec-owned BlobKey.
Put must be idempotent for equal bytes and must reject a different value at an existing key. Get must return no more than maxBytes; this lets a store enforce the codec's bounded read policy before allocating unbounded content.
type Codec ¶
type Codec struct {
// contains filtered or unexported fields
}
Codec implements Temporal's PayloadCodec using a local zstd/blob transformation chain.
func (*Codec) CheckCompatibility ¶
CheckCompatibility verifies retained v1 inline, zstd, and remote payload vectors before accepting work.
func (*Codec) DataConverter ¶
func (codec *Codec) DataConverter() converter.DataConverter
DataConverter returns the local Temporal DataConverter that owns payload selection transparently.
type GarbageCollector ¶
type GarbageCollector struct {
// contains filtered or unexported fields
}
GarbageCollector computes and applies only explicitly authorized, age-bounded deletion.
func NewGarbageCollector ¶
func NewGarbageCollector(coordinator RetentionCoordinator, prefix string, minimumAge time.Duration) (*GarbageCollector, error)
NewGarbageCollector creates the retention-only deletion coordinator.
type MemoryBlobStore ¶
type MemoryBlobStore struct {
// contains filtered or unexported fields
}
MemoryBlobStore is a concurrent in-memory BlobStore for tests and local deterministic consumers. It is not durable storage.
func NewMemoryBlobStore ¶
func NewMemoryBlobStore() *MemoryBlobStore
NewMemoryBlobStore creates a concurrent in-memory immutable BlobStore.
func (*MemoryBlobStore) Count ¶
func (store *MemoryBlobStore) Count() int
Count returns the number of stored objects. It is intended for deterministic tests.
func (*MemoryBlobStore) Delete ¶
func (store *MemoryBlobStore) Delete(ctx context.Context, key BlobKey) error
Delete removes key from the deterministic test store. Production object stores must make deletion an explicit retention/GC operation rather than a normal codec concern.
type Observation ¶
type Observation struct {
Operation string
Selection string
InputSizeBytes int
OutputSizeBytes int
}
Observation is a bounded payload codec observation suitable for a metrics adapter.
type Observer ¶
type Observer interface {
ObservePayload(Observation)
}
Observer records bounded codec observations without receiving payload bytes or blob keys.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option configures a Codec. It is sealed so codecs cannot receive unchecked configuration.
func WithBlobPrefix ¶
WithBlobPrefix configures the explicit object-store prefix that owns this codec's content-addressed keys.
func WithIOTimeout ¶
WithIOTimeout configures the finite background I/O bound required by Temporal's payload codec API.
func WithMaximumBlobBytes ¶
WithMaximumBlobBytes configures the maximum immutable payload object the codec will write or read.
func WithObserver ¶
WithObserver configures a bounded metrics observer for codec outcomes.
type RetentionCoordinator ¶
type RetentionCoordinator interface {
List(context.Context, string) ([]BlobObject, error)
FenceAndDeleteUnreferenced(context.Context, BlobKey, time.Time, time.Time) (deleted bool, err error)
}
RetentionCoordinator owns both the authoritative reference fence and deletion protocol.
FenceAndDeleteUnreferenced must atomically fence new authoritative reference creation, prove that the object has no authoritative reference, and condition deletion on the listed object creation identity. When an external object store cannot be deleted under that durable fence, it returns deleted=false and leaves a durable tombstone/reconciliation record rather than guessing. Codec deliberately does not implement or receive this interface.
type UIHandlerOption ¶
type UIHandlerOption interface {
// contains filtered or unexported methods
}
UIHandlerOption configures the authenticated Temporal UI inspection handler.
func WithTemporalUINamespaces ¶
func WithTemporalUINamespaces(namespaces ...string) UIHandlerOption
WithTemporalUINamespaces limits the handler to the declared Temporal namespaces.
func WithTemporalUIOrigins ¶
func WithTemporalUIOrigins(origins ...string) UIHandlerOption
WithTemporalUIOrigins limits browser access to the declared Temporal UI origins.
func WithTemporalUIRequestAuthorizer ¶
func WithTemporalUIRequestAuthorizer(authorizer UIRequestAuthorizer) UIHandlerOption
WithTemporalUIRequestAuthorizer requires trusted authentication and namespace authorization.
type UIRequestAuthorizer ¶
type UIRequestAuthorizer interface {
AuthorizeTemporalPayloadUI(request *http.Request, namespace string) (AuthorizationDecision, error)
}
UIRequestAuthorizer authenticates a Temporal UI request and authorizes its requested namespace. Implementations must establish identity from a trusted boundary (for example verified OIDC middleware or an mTLS peer), rather than treating X-Namespace, Origin, or a network location as authentication.
The handler passes the full request so an implementation can read trusted authentication context installed by its enclosing middleware. It must not retain or log request credentials.
type UIRequestAuthorizerFunc ¶
type UIRequestAuthorizerFunc func(request *http.Request, namespace string) (AuthorizationDecision, error)
UIRequestAuthorizerFunc adapts a function into a UIRequestAuthorizer.
func (UIRequestAuthorizerFunc) AuthorizeTemporalPayloadUI ¶
func (authorizer UIRequestAuthorizerFunc) AuthorizeTemporalPayloadUI(request *http.Request, namespace string) (AuthorizationDecision, error)
AuthorizeTemporalPayloadUI calls authorizer.