reload

package
v0.1.0-alpha.9 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentChange

type AgentChange struct {
	Name string
	Old  config.Agent
	New  config.Agent
}

AgentChange represents a modification to an existing agent.

type AgentDiff

type AgentDiff struct {
	Added    []config.Agent
	Removed  []config.Agent
	Modified []AgentChange
}

AgentDiff contains changes to agents.

type ConfigDiff

type ConfigDiff struct {
	MCPServers MCPServerDiff
	Agents     AgentDiff
	Resources  ResourceDiff
	// NetworkChanged indicates if the network config changed (requires full restart)
	NetworkChanged bool
}

ConfigDiff represents the differences between two stack configurations.

func ComputeDiff

func ComputeDiff(old, new *config.Stack) *ConfigDiff

ComputeDiff computes the differences between two stack configurations.

func (*ConfigDiff) IsEmpty

func (d *ConfigDiff) IsEmpty() bool

IsEmpty returns true if there are no changes.

type Handler

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

Handler manages hot reload for a running stack.

func NewHandler

func NewHandler(stackPath string, currentCfg *config.Stack, gateway *mcp.Gateway, rt *runtime.Orchestrator, port, basePort, gatewayPort int) *Handler

NewHandler creates a reload handler.

func (*Handler) CurrentConfig

func (h *Handler) CurrentConfig() *config.Stack

CurrentConfig returns the current stack configuration.

func (*Handler) Reload

func (h *Handler) Reload(ctx context.Context) (*ReloadResult, error)

Reload reloads the configuration from disk and applies changes.

func (*Handler) SetLogger

func (h *Handler) SetLogger(logger *slog.Logger)

SetLogger sets the logger.

func (*Handler) SetNoExpand

func (h *Handler) SetNoExpand(noExpand bool)

SetNoExpand sets whether to skip OpenAPI env var expansion.

func (*Handler) SetRegisterServerFunc

func (h *Handler) SetRegisterServerFunc(fn func(ctx context.Context, server config.MCPServer, hostPort int) error)

SetRegisterServerFunc sets the callback for registering MCP servers.

type MCPServerChange

type MCPServerChange struct {
	Name string
	Old  config.MCPServer
	New  config.MCPServer
}

MCPServerChange represents a modification to an existing MCP server.

type MCPServerDiff

type MCPServerDiff struct {
	Added    []config.MCPServer
	Removed  []config.MCPServer
	Modified []MCPServerChange
}

MCPServerDiff contains changes to MCP servers.

type ReloadResult

type ReloadResult struct {
	Success  bool     `json:"success"`
	Message  string   `json:"message"`
	Added    []string `json:"added,omitempty"`
	Removed  []string `json:"removed,omitempty"`
	Modified []string `json:"modified,omitempty"`
	Errors   []string `json:"errors,omitempty"`
}

ReloadResult contains the result of a reload operation.

type ResourceChange

type ResourceChange struct {
	Name string
	Old  config.Resource
	New  config.Resource
}

ResourceChange represents a modification to an existing resource.

type ResourceDiff

type ResourceDiff struct {
	Added    []config.Resource
	Removed  []config.Resource
	Modified []ResourceChange
}

ResourceDiff contains changes to resources.

type Watcher

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

Watcher monitors a stack file for changes and triggers reload.

func NewWatcher

func NewWatcher(path string, onChange func() error) *Watcher

NewWatcher creates a file watcher for the given stack path. onChange is called when the file changes (after debouncing).

func (*Watcher) SetDebounce

func (w *Watcher) SetDebounce(d time.Duration)

SetDebounce sets the debounce duration for file changes.

func (*Watcher) SetLogger

func (w *Watcher) SetLogger(logger *slog.Logger)

SetLogger sets the logger for watcher events.

func (*Watcher) Watch

func (w *Watcher) Watch(ctx context.Context) error

Watch starts watching the file for changes. Blocks until context is cancelled.

We watch the parent directory rather than the file directly because most editors use atomic saves (write to temp file, then rename). When a file is renamed over the watched file, fsnotify loses track of it. Watching the directory catches all events including renames.

Jump to

Keyboard shortcuts

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