component package - github.com/asenawritescode/kora/component - Go Packages

component

package
v0.9.9 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 6 Imported by: 0

Documentation

Overview

Package component defines the typed component manifest (PLUGIN-004): what a component provides, what it requires, and which events it emits and handles. The normalized typed model is authoritative; YAML and JSON are lossless interchange only, and validation fails at load time rather than at runtime.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BindingStrategy

type BindingStrategy string

BindingStrategy describes how a component should be bound to capability providers when a runtime resolves its requirements.

const (
	BindingStrategyDynamic   BindingStrategy = "dynamic"
	BindingStrategyPerOp     BindingStrategy = "per-operation"
	BindingStrategyPerReq    BindingStrategy = "per-request"
	BindingStrategyPerTenant BindingStrategy = "per-tenant"
	BindingStrategyFixed     BindingStrategy = "fixed"
)

type ErrManifestInvalid

type ErrManifestInvalid struct {
	Path       string
	Detail     string
	Suggestion string
}

ErrManifestInvalid is a typed validation failure carrying the key path, a human detail, and an optional "did you mean" suggestion.

func (*ErrManifestInvalid) Error

func (e *ErrManifestInvalid) Error() string

type EventDecl

type EventDecl struct {
	Type    string `yaml:"type" json:"type"`
	Version int    `yaml:"version" json:"version"`
}

EventDecl references one event envelope type and its schema version.

type EventTypeRegistry

type EventTypeRegistry func(eventType string) bool

EventTypeRegistry reports whether an event envelope type is registered. Callers pass the canonical event registry; unknown types fail validation.

type EventsDecl

type EventsDecl struct {
	Emits   []EventDecl `yaml:"emits" json:"emits,omitempty"`
	Handles []EventDecl `yaml:"handles" json:"handles,omitempty"`
}

EventsDecl declares the event types a component emits and handles.

type Lifecycle

type Lifecycle string

Lifecycle declares the expected runtime lifecycle posture for the component.

const (
	LifecycleActive       Lifecycle = "active"
	LifecycleDegraded     Lifecycle = "degraded"
	LifecycleWaiting      Lifecycle = "waiting"
	LifecycleStopping     Lifecycle = "stopping"
	LifecycleInactive     Lifecycle = "inactive"
	LifecycleExperimental Lifecycle = "experimental"
)

type Manifest

type Manifest struct {
	Name            string          `yaml:"name" json:"name"`
	Version         string          `yaml:"version" json:"version"`
	Runtime         Runtime         `yaml:"runtime" json:"runtime"`
	BindingStrategy BindingStrategy `yaml:"binding_strategy,omitempty" json:"binding_strategy,omitempty"`
	Lifecycle       Lifecycle       `yaml:"lifecycle,omitempty" json:"lifecycle,omitempty"`
	Provides        []string        `yaml:"provides" json:"provides,omitempty"`
	Requires        []string        `yaml:"requires" json:"requires,omitempty"`
	Events          EventsDecl      `yaml:"events" json:"events,omitempty"`
}

Manifest is the typed component definition.

func LoadJSON

func LoadJSON(data []byte, events EventTypeRegistry) (*Manifest, error)

LoadJSON decodes a JSON manifest strictly (unknown fields rejected) and validates it. It returns a typed *ErrManifestInvalid for unknown keys or semantic validation failures.

func LoadYAML

func LoadYAML(data []byte, events EventTypeRegistry) (*Manifest, error)

LoadYAML decodes a YAML manifest strictly and validates it. YAML is interchange only; the typed Manifest is authoritative.

func (Manifest) Validate

func (m Manifest) Validate(events EventTypeRegistry) error

Validate checks name, version, runtime, capability duplicates, and event types. It returns the first failure as a typed *ErrManifestInvalid.

type Runtime

type Runtime string

Runtime identifies the execution substrate for a component.

const (
	RuntimeGoja   Runtime = "goja"
	RuntimeWasm   Runtime = "wasm"
	RuntimeNative Runtime = "native"
)

Jump to

Keyboard shortcuts

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