hotswap

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package hotswap aggregates imports that are required by the hot-swap feature but are not yet referenced in the early scaffolding stages. The blank import ensures the module dependency is added to go.mod so that later stages can rely on it without running `go get` manually.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveWorkflowPath

func ResolveWorkflowPath(name string) string

Helper resolving canonical path mirroring repository default logic.

Types

type Action

type Action int

Action represents the type of change detected on the workspace resource.

const (
	// AddOrUpdate signals that a file was created or modified.
	AddOrUpdate Action = iota
	// Delete signals that a file was removed or renamed so it is no longer available.
	Delete
)

type LoaderFunc

type LoaderFunc[T any] func(ctx context.Context, name string) (T, error)

LoaderFunc loads an object identified by name from an external source. It usually parses YAML/JSON from disk and returns a fully validated object.

type Manager

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

Manager orchestrates hot-swap live reload across multiple workspace kinds. Callers should create one instance per executor and invoke Start/Stop in sync with the executor lifecycle.

func NewManager

func NewManager(root string, debounce time.Duration) (*Manager, error)

NewManager builds a Manager watching workspace root. Debounce specifies the minimum interval between two events for the same file before the latter is forwarded; use 0 for no debouncing.

func (*Manager) Register

func (m *Manager) Register(kind string, r Reloadable)

Register attaches a Reloadable registry to a workspace kind such as workspace.KindAgent. Must be called before Start.

func (*Manager) Start

func (m *Manager) Start() error

Start begins watching the workspace and dispatching change events. It spawns goroutines and returns immediately. Calling Start twice is a no-op.

func (*Manager) Stop

func (m *Manager) Stop()

Stop shuts down the manager and underlying watcher. Safe for repeated use.

type Reloadable

type Reloadable interface {
	Reload(ctx context.Context, name string, what Action) error
}

Reloadable is implemented by any registry/loader pair that can accept hot-swap notifications originating from the workspace file watcher.

The HotSwapManager invokes Reload whenever a YAML file inside the workspace is added, changed or deleted.

name – base file name without extension (e.g. "chat" for chatter.yaml) what – kind of change (AddOrUpdate/Delete).

Implementations are expected to be thread-safe.

func NewAdaptor

func NewAdaptor[T any](load LoaderFunc[T], set SetFunc[T], remove RemoveFunc) Reloadable

NewAdaptor builds a Reloadable that delegates to the provided callbacks.

func NewAgentAdaptor

func NewAgentAdaptor(loader *agentloader.Service, finder *agentfinder.Finder) Reloadable

NewAgentAdaptor wires together the agent loader and finder so that workspace file changes picked up by the HotSwap manager seamlessly refresh the in-memory cache used by the executor.

func NewEmbedderAdaptor

func NewEmbedderAdaptor(loader *embedload.Service, finder *embedfinder.Finder) Reloadable

NewEmbedderAdaptor wires embedder loader + finder for hot-swap.

func NewExtensionAdaptor added in v0.2.1

func NewExtensionAdaptor(repo *extensionrepo.Repository, finder *extfinder.Finder) Reloadable

NewExtensionAdaptor wires the extensions repository to the in-memory finder so edits in the workspace are reflected live.

func NewMCPAdaptor

func NewMCPAdaptor(group *mcpcfg.Group[*mcpcfg.MCPClient]) Reloadable

NewMCPAdaptor hot-swaps MCP client option YAMLs. It reloads the file into the provided Group so that new orchestrations or restarts see the updated servers.

Caveat: The running fluxor-mcp service created during executor bootstrap is *not* updated here. Users must restart Agently (or execute a future dynamic-reconfigure endpoint) for the new server list to take effect.

func NewModelAdaptor

func NewModelAdaptor(loader *modelload.Service, finder *modelfinder.Finder) Reloadable

NewModelAdaptor wires model config loader with model finder to support live reload when YAML files under $WORKSPACE/models/ change.

func NewOAuthAdaptor

func NewOAuthAdaptor(loader *oauthloader.Service, finder *oauthfinder.Finder) Reloadable

NewOAuthAdaptor links oauth loader and finder into Reloadable for Manager.

func NewWorkflowAdaptor

func NewWorkflowAdaptor(
	loadRaw func(ctx context.Context, name string) ([]byte, error),
	absPathFn func(name string) string,
	refresh func(location string) error,
	upsert func(location string, data []byte) error,
) Reloadable

WorkflowAdaptor pushes workspace YAML changes into a running Fluxor runtime through user-supplied callbacks so that internal/hotswap avoids importing the fluxor package (keeps dependency graph acyclic).

loadRaw – returns raw YAML bytes for a workflow name (without .yaml). absPathFn – resolves the canonical location string that Runtime uses as key

(usually workspace/kind/<name>.yaml).

refresh – invalidates cached copy (called on Delete when upsert is nil). upsert – optional; when non-nil it is used on AddOrUpdate so that runtime

is updated immediately without next-load round-trip.

type RemoveFunc

type RemoveFunc func(name string)

RemoveFunc deletes a value from the registry by name. It must be safe when the entry does not exist.

type SetFunc

type SetFunc[T any] func(name string, value T)

SetFunc stores a value under the given name inside an in-memory registry. Implementations must be thread-safe.

Jump to

Keyboard shortcuts

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