component

package
v0.4.0-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package component provides the Component interface and ComponentHost for managing pluggable runtime extensions with lifecycle management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Capability

type Capability string

Capability identifies a component capability.

const (
	CapabilityAgentMemory Capability = "agent.memory"
	CapabilityAgentPeer   Capability = "agent.peer"
	CapabilityAgentMCP    Capability = "agent.mcp"
	CapabilityAgentTool   Capability = "agent.tooling"
)

type Component

type Component interface {
	Name() string
	Capabilities() []Capability
	Start(ctx context.Context) error
	Close() error
}

Component is a pluggable runtime extension.

Components live outside core business logic, but can be mounted into a Host and started/stopped with app lifecycle.

type Host

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

Host stores and manages lifecycle for registered components. It is goroutine-safe.

func NewHost

func NewHost() *Host

NewHost creates an empty component host.

func (*Host) ByCapability

func (h *Host) ByCapability(cap Capability) []Component

ByCapability returns a snapshot of components exposing cap.

func (*Host) CloseAll

func (h *Host) CloseAll() error

CloseAll closes all registered components and returns the first error.

func (*Host) Get

func (h *Host) Get(name string) (Component, bool)

Get returns a component by name.

func (*Host) Names

func (h *Host) Names() []string

Names returns a snapshot of component names.

func (*Host) Register

func (h *Host) Register(c Component) error

Register adds a component. Names must be unique.

func (*Host) StartAll

func (h *Host) StartAll(ctx context.Context) error

StartAll starts all components. Stops on first error.

Jump to

Keyboard shortcuts

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