event

package
v0.2.42 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Acceptance added in v0.2.31

type Acceptance struct {
	Tenant string
	Stack  string
}

Acceptance is the trusted routing outcome at the moment the chassis commits to running a tenant's stack: the pinned tenant and the stack the boot handoff routed into, read from immutable pipeline state (processor.TenantObserver), never from the envelope.

type DispatchResult added in v0.2.31

type DispatchResult struct {
	Payload Payload
	Tenant  string // "" or "_sys": the run never left the system tenant
	Stack   string // the routed stack; "" when unrouted
	// Ingress and HostnameVerified are the rest of the route the boot
	// handoff promoted (`_txc.ingress`, `_txc.hostname_verified`), so an
	// inlet that pins a connection can pre-stamp the same route on the
	// connection's later events.
	Ingress          string
	HostnameVerified bool
	Err              error // pipeline error, if any
}

DispatchResult is the bus loop's trusted summary of one run: the final payload plus the tenant and stack the chassis pinned — read from immutable pipeline state (processor.TenantObserver), never parsed out of the author-visible envelope, whose `_txc.tenant` a stack could rewrite. An inlet that needs the routing outcome (the TCP head deciding whether a connection stays open) sets Envelope.ResultCh and leaves ResCh nil.

type Envelope

type Envelope struct {
	Ctx     context.Context
	Payload *Payload
	ResCh   chan Payload
	// ResultCh, when set, replaces ResCh: the bus loop answers once with
	// the run's DispatchResult (final payload + trusted tenant/stack)
	// after the pipeline returns. Streaming responses need ResCh.
	ResultCh chan DispatchResult
	// Accepted, when set, is told once — before the tenant's stack runs
	// — that the chassis has accepted this event for execution: routed
	// out of _sys/boot into a concrete tenant and admitted. An inlet that
	// delivers from a durable outbox closes its claim on this signal
	// rather than at completion, so a long run never holds a delivery
	// claim open. The send is non-blocking: buffer the channel at 1. It
	// is never sent for a run that stays in _sys, or for one admission
	// denies (those answer on ResCh/ResultCh as before).
	Accepted chan Acceptance
	Rid      string
	Src      string
}

func PackageJSON

func PackageJSON(ctx context.Context, raw string, res chan Payload, src string) *Envelope

type OpsHandler

type OpsHandler interface {
	Route(ctx context.Context, opName string, in []byte, out []byte) (Payload, error)
}

type OpsHandlerFunc

type OpsHandlerFunc func(ctx context.Context, opName string, in []byte, out []byte) (Payload, error)

OpsHandlerFunc adapts a plain function to the OpsHandler interface, in the same shape as http.HandlerFunc. Built-in core ops (e.g. txco://noop) are registered as OpsHandlerFunc values.

func (OpsHandlerFunc) Route

func (f OpsHandlerFunc) Route(ctx context.Context, opName string, in []byte, out []byte) (Payload, error)

Route satisfies OpsHandler.

type Payload

type Payload struct {
	Raw  string `json:"raw,omitempty"`
	Type Type   `json:"type,omitempty"`
	Meta string `json:"meta,omitempty"`
}

func CreateJSONPayload

func CreateJSONPayload(raw string) Payload

func ErrResponse

func ErrResponse(errMsg string, raw string, err error) (Payload, error)

func (Payload) String

func (payload Payload) String() string

type RawJSON

type RawJSON string

func NewJSON

func NewJSON(raw string) RawJSON

func (RawJSON) CreateJSONPayload

func (raw RawJSON) CreateJSONPayload() (Payload, error)

func (RawJSON) Set

func (raw RawJSON) Set(insertPoint string, val interface{}) RawJSON

func (RawJSON) String

func (raw RawJSON) String() string

type Type

type Type int

Event payloads may have different types

const (
	// Null is an empty message, an ACK
	Null Type = iota

	// JSON is a raw block of JSON
	JSON

	// Error
	ErrorStr

	// StreamHead carries the response status + headers snapshot for a
	// streamed HTTP response. Sent once, before any StreamChunk; the
	// response writer writes the head and switches into incremental-flush mode.
	StreamHead

	// StreamChunk carries a block of raw (already-decoded) response body
	// bytes in Raw, to be written and flushed immediately.
	StreamChunk

	// StreamEnd terminates a streamed response. No body; the response writer
	// returns once it receives this.
	StreamEnd
)

func (Type) String

func (t Type) String() string

String returns a string representation of the type.

Jump to

Keyboard shortcuts

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