runtime

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxPayloadBytes caps stdin and argv JSON payloads accepted by runtime decoders.
	MaxPayloadBytes = 1 << 20
)

Variables

This section is empty.

Functions

func CanonicalInvocationName

func CanonicalInvocationName(platform PlatformID, raw string) string

func DecodeJSONPayload added in v1.1.0

func DecodeJSONPayload[T any](body []byte, label string) (*T, error)

func InternalHookTypeMismatch

func InternalHookTypeMismatch(name string) error

func NormalizeHookName

func NormalizeHookName(name string) string

func ValidatePayloadSize added in v1.1.0

func ValidatePayloadSize(body []byte, label string) error

Types

type CapabilityID

type CapabilityID string

type CarrierKind

type CarrierKind string
const (
	CarrierStdinJSON CarrierKind = "stdin_json"
	CarrierArgvJSON  CarrierKind = "argv_json"
)

type Descriptor

type Descriptor struct {
	Platform PlatformID
	Event    EventID
	Carrier  CarrierKind
	Decode   func(Envelope) (any, string, error)
	Encode   func(any) Result
}

type DescriptorLookup

type DescriptorLookup func(platform PlatformID, event EventID) (Descriptor, bool)

type Engine

type Engine struct {
	Args          []string
	IO            IO
	Env           Env
	Logger        Logger
	Resolver      Resolver
	Lookup        DescriptorLookup
	BuildEnvelope EnvelopeBuilder
	Handlers      *HandlerRegistry
	Middleware    []Middleware
}

func (*Engine) Dispatch

func (e *Engine) Dispatch(ctx context.Context) Result

type Env

type Env interface {
	LookupEnv(string) (string, bool)
}

type Envelope

type Envelope struct {
	Invocation Invocation
	Args       []string
	Stdin      []byte
	Env        Env
}

type EnvelopeBuilder

type EnvelopeBuilder func(ctx context.Context, inv Invocation, carrier CarrierKind, args []string, io IO, env Env) (Envelope, error)

type EventID

type EventID string

type Handled

type Handled struct {
	Value any
	Err   error
}

type HandlerRegistry

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

func NewHandlerRegistry

func NewHandlerRegistry() *HandlerRegistry

func (*HandlerRegistry) Lookup

func (r *HandlerRegistry) Lookup(platform PlatformID, event EventID) (TypedHandler, bool)

func (*HandlerRegistry) Register

func (r *HandlerRegistry) Register(platform PlatformID, event EventID, handler TypedHandler)

type IO

type IO interface {
	ReadStdin(ctx context.Context) ([]byte, error)
	WriteStdout([]byte) error
	WriteStderr(string) error
}

type Invocation

type Invocation struct {
	Platform PlatformID
	Event    EventID
	RawName  string
}

type InvocationContext

type InvocationContext struct {
	Context    context.Context
	Invocation Invocation
	Descriptor Descriptor
	Env        Env
	Logger     Logger
}

type InvocationKind

type InvocationKind string
const (
	InvocationArgvCommand         InvocationKind = "argv_command"
	InvocationArgvCommandCaseFold InvocationKind = "argv_command_casefold"
	InvocationArgvPayload         InvocationKind = "argv_payload"
	InvocationEnvMarker           InvocationKind = "env_marker"
	InvocationCustomResolver      InvocationKind = "custom_resolver"
)

type Logger

type Logger interface {
	Info(string)
	Error(string)
}

type MaturityLevel

type MaturityLevel string
const (
	MaturityStable       MaturityLevel = "stable"
	MaturityBeta         MaturityLevel = "beta"
	MaturityExperimental MaturityLevel = "experimental"
)

type Middleware

type Middleware func(Next) Next

func RecoveryMiddleware

func RecoveryMiddleware(log Logger) Middleware

type Next

type Next func(InvocationContext) Handled

func Chain

func Chain(middleware []Middleware, final Next) Next

type NopLogger

type NopLogger struct{}

func (NopLogger) Error

func (NopLogger) Error(string)

func (NopLogger) Info

func (NopLogger) Info(string)

type PlatformID

type PlatformID string

type RegistrarBackend

type RegistrarBackend interface {
	Register(platform PlatformID, event EventID, handler TypedHandler)
	RegisterCustom(rawName string, desc Descriptor, handler TypedHandler) error
}

type Resolver

type Resolver func(args []string, env Env) (Invocation, error)

type Result

type Result struct {
	ExitCode int
	Stdout   []byte
	Stderr   string
}

type SupportEntry

type SupportEntry struct {
	Platform        PlatformID
	Event           EventID
	Status          SupportStatus
	Maturity        MaturityLevel
	V1Target        bool
	InvocationKind  InvocationKind
	Carrier         CarrierKind
	TransportModes  []TransportMode
	ScaffoldSupport bool
	ValidateSupport bool
	Capabilities    []CapabilityID
	Summary         string
	LiveTestProfile string
}

type SupportStatus

type SupportStatus string
const (
	StatusRuntimeSupported SupportStatus = "runtime_supported"
	StatusScaffoldOnly     SupportStatus = "scaffold_only"
	StatusDeferred         SupportStatus = "deferred"
)

type TransportMode

type TransportMode string
const (
	ProcessMode TransportMode = "process"
	HybridMode  TransportMode = "hybrid"
	DaemonMode  TransportMode = "daemon"
)

type TypedHandler

type TypedHandler func(InvocationContext, any) Handled

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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