Help us shape the future of Go! Take the 2026 Go Developer Survey

protocol

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package protocol owns Temporal raw JSON and native failure envelopes.

Index

Constants

View Source
const ErrorType = "arkoren.error"

ErrorType is the Temporal application error type of a failure that carries the workflow.EncodeError envelope as its first detail.

Variables

View Source
var ErrTerminated = workflow.NewError("temporal.terminated", "temporal: workflow terminated")

ErrTerminated reports a run that an operator terminated. Status reports such a run as workflow.Failed.

Functions

func Failure

func Failure(err error) error

Failure returns the Temporal error that carries err and its envelope.

func FromTemporal

func FromTemporal(err error) error

FromTemporal maps an error of the Temporal client or SDK to a workflow error. It walks the SDK's single-cause chain in order: an outer timeout must not be masked by its previous application failure, and an outer application failure must not become its timeout cause. Unknown errors, including composite errors outside the native failure chain, pass through without value equality.

Types

type Payload

type Payload []byte

Payload carries the facade bytes, which are always JSON, as a raw JSON value in the Temporal payload, so the Temporal UI shows plain JSON. A named type keeps the SDK from using its binary converter.

func DecodeInput

func DecodeInput(in Payload) (Payload, map[string]string, error)

DecodeInput accepts both traced and legacy inputs. Decoding is deterministic and does not create spans, read the clock, or change orchestration history.

func EncodeInput

func EncodeInput(in Payload, carrier map[string]string) (Payload, error)

EncodeInput attaches a carrier without modifying the facade envelope. JSON encoding errors are returned rather than submitting a partially encoded run.

func (Payload) MarshalJSON

func (value Payload) MarshalJSON() ([]byte, error)

MarshalJSON returns the bytes as they are, or null when empty. Nonempty results alias the retained payload and must be treated as read-only by native converters; the method never changes the persisted envelope shape.

Example:

value := payload(`{"v":true}`)
encoded, err := value.MarshalJSON()
if err != nil {
	return err
}
_ = string(encoded) // {"v":true}

func (*Payload) UnmarshalJSON

func (value *Payload) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps a copy of the raw value. It may reuse the receiver's storage, but never retains the input slice. Syntax validation belongs to the surrounding native JSON decoder.

Example:

var value payload
input := []byte(`{"v":true}`)
if err := value.UnmarshalJSON(input); err != nil {
	return err
}
clear(input) // The decoded payload remains unchanged.

Jump to

Keyboard shortcuts

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