registry

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventType

type EventType int
const (
	EventRegistered EventType = iota
	EventUnregistered
	EventHealthChanged
)

type HealthStatus

type HealthStatus string
const (
	HealthUnknown   HealthStatus = "unknown"
	HealthHealthy   HealthStatus = "healthy"
	HealthUnhealthy HealthStatus = "unhealthy"
)

type LifecycleManager

type LifecycleManager interface {
	Start(ctx context.Context, config ServerConfig) (ServerHandle, error)
	Stop(ctx context.Context, id string) error
	Kill(ctx context.Context, id string) error
	Restart(ctx context.Context, id string) error
	Status(ctx context.Context, id string) (ServerStatus, error)
	List(ctx context.Context) ([]ServerStatus, error)
}

func NewLifecycleManager

func NewLifecycleManager(logger *slog.Logger) LifecycleManager

type MatchCriteria

type MatchCriteria struct {
	Capabilities []string
	Transport    TransportType
	MinHealth    HealthStatus
	MaxLoad      float64
}

type Registry

type Registry interface {
	Register(ctx context.Context, entry ServerEntry) error
	Unregister(ctx context.Context, id string) error
	Update(ctx context.Context, entry ServerEntry) error

	Get(ctx context.Context, id string) (*ServerEntry, error)
	List(ctx context.Context) ([]*ServerEntry, error)
	FindByCapability(ctx context.Context, capability string) ([]*ServerEntry, error)
	FindByTransport(ctx context.Context, transport TransportType) ([]*ServerEntry, error)
	FindBest(ctx context.Context, criteria MatchCriteria) (*ServerEntry, error)

	UpdateHealth(ctx context.Context, id string, health HealthStatus) error
	ListUnhealthy(ctx context.Context) ([]*ServerEntry, error)

	Save(ctx context.Context) error
	Load(ctx context.Context) error

	Subscribe(ch chan<- RegistryEvent) func()
}

func NewRegistry

func NewRegistry(logger *slog.Logger, persistPath string) Registry

type RegistryEvent

type RegistryEvent struct {
	Type    EventType
	Server  *ServerEntry
	Details string
}

type ServerConfig

type ServerConfig struct {
	ID      string
	Name    string
	Command []string
	Env     []string
	Dir     string
	Port    int
}

type ServerEntry

type ServerEntry struct {
	ID           string
	Config       *ServerConfig
	Address      string
	Transport    TransportType
	Capabilities []string
	Health       HealthStatus
	Stats        ServerStats
	RegisteredAt time.Time
	LastSeenAt   time.Time
}

type ServerHandle

type ServerHandle struct {
	ID     string
	Config ServerConfig
	PID    int
}

type ServerState

type ServerState string
const (
	StateRunning  ServerState = "running"
	StateStopped  ServerState = "stopped"
	StateError    ServerState = "error"
	StateStarting ServerState = "starting"
)

type ServerStats

type ServerStats struct {
	RequestCount int64
	ErrorCount   int64
	AvgLatencyMs float64
	Load         float64
}

type ServerStatus

type ServerStatus struct {
	ID         string
	State      ServerState
	Uptime     time.Duration
	MemoryMB   float64
	CPUPercent float64
	ExitCode   int
	Error      string
}

type ToolEntry

type ToolEntry struct {
	Name      string
	Namespace string
	ServerID  string
}

type ToolEvent

type ToolEvent struct {
	Type     ToolEventType
	ServerID string
	ToolName string
	Tool     ToolEntry
}

type ToolEventType

type ToolEventType int
const (
	ToolEventRegistered ToolEventType = iota
	ToolEventUnregistered
)

type ToolMatch

type ToolMatch struct {
	Tool    ToolEntry
	Score   float64
	MatchOn string
}

type ToolRegistry

type ToolRegistry interface {
	RegisterTool(ctx context.Context, serverID, toolName string) error
	UnregisterTool(ctx context.Context, serverID, toolName string) error
	GetToolServer(ctx context.Context, toolName string) (string, error)
	SearchTools(ctx context.Context, query string) []ToolMatch
	ListAllTools(ctx context.Context) []ToolEntry
	SubscribeTools(ch chan<- ToolEvent) func()
}

func NewToolRegistry

func NewToolRegistry(logger interface{ Debug(msg string, args ...any) }) ToolRegistry

type TransportType

type TransportType string
const (
	TransportStdio TransportType = "stdio"
	TransportHTTP  TransportType = "http"
	TransportSSE   TransportType = "sse"
)

Jump to

Keyboard shortcuts

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