component

package
v0.7.0-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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