Documentation
¶
Index ¶
- func ExitCleanIfAlreadyRunning(startErr error, port int) bool
- func SetBuildVersion(v string, metadata ...string)
- func StartPackageRegistryWatcher(parentCtx context.Context, agentfieldHome string, ...) (context.CancelFunc, error)
- func SyncPackagesFromRegistry(agentfieldHome string, storageProvider packageStorage) error
- type AgentFieldServer
- func (s *AgentFieldServer) BeginDrain()
- func (s *AgentFieldServer) IsDraining() bool
- func (s *AgentFieldServer) ListReasoners(ctx context.Context, _ *adminpb.ListReasonersRequest) (*adminpb.ListReasonersResponse, error)
- func (s *AgentFieldServer) Start() error
- func (s *AgentFieldServer) Stop() error
- type InstallationRegistry
- type InstalledPackage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExitCleanIfAlreadyRunning ¶
ExitCleanIfAlreadyRunning inspects a failed server startup (storage init / server creation, or the HTTP bind). When a healthy AgentField control plane already answers on the configured port, it logs an honest line and returns true — the caller should exit 0. This makes `agentfield server` idempotent under supervisors: launchd's KeepAlive={SuccessfulExit:false} reads exit 0 as a clean stop and does not relaunch, so a second instance racing the app's direct-spawned server stops instead of thrashing in a crash loop. For any other error (foreign service on the port, or a startup failure with no incumbent) it returns false and the caller keeps its non-zero exit.
func SetBuildVersion ¶
SetBuildVersion records the control plane's build metadata for runtime introspection surfaces. Call once at startup, before NewAgentFieldServer. The optional values are commit and build date, in that order.
func StartPackageRegistryWatcher ¶
func StartPackageRegistryWatcher(parentCtx context.Context, agentfieldHome string, storageProvider packageStorage) (context.CancelFunc, error)
StartPackageRegistryWatcher watches the installed.yaml registry and keeps storage in sync.
func SyncPackagesFromRegistry ¶
SyncPackagesFromRegistry reconciles the database with installed.yaml: every registry entry is upserted with an installed status (upgrading pre-seeded catalog rows), and previously-installed rows missing from the registry are downgraded to uninstalled. An absent registry file means nothing is installed and only triggers the downgrade pass.
Types ¶
type AgentFieldServer ¶
type AgentFieldServer struct {
adminpb.UnimplementedAdminReasonerServiceServer
Router *gin.Engine
// contains filtered or unexported fields
}
AgentFieldServer represents the core AgentField orchestration service.
func NewAgentFieldServer ¶
func NewAgentFieldServer(cfg *config.Config) (*AgentFieldServer, error)
NewAgentFieldServer creates a new instance of the AgentFieldServer.
func (*AgentFieldServer) BeginDrain ¶
func (s *AgentFieldServer) BeginDrain()
BeginDrain marks the control plane as shutting down so readiness probes start failing while the HTTP listener is still open and still serving. It is safe to call more than once and never blocks. Liveness (/health, /api/v1/health) is deliberately untouched: the process is alive and must not be killed by the kubelet mid-drain.
func (*AgentFieldServer) IsDraining ¶
func (s *AgentFieldServer) IsDraining() bool
IsDraining reports whether shutdown draining has begun.
func (*AgentFieldServer) ListReasoners ¶
func (s *AgentFieldServer) ListReasoners(ctx context.Context, _ *adminpb.ListReasonersRequest) (*adminpb.ListReasonersResponse, error)
ListReasoners implements the admin gRPC surface for listing registered reasoners.
func (*AgentFieldServer) Start ¶
func (s *AgentFieldServer) Start() error
Start initializes and starts the AgentFieldServer.
func (*AgentFieldServer) Stop ¶
func (s *AgentFieldServer) Stop() error
Stop gracefully shuts down the AgentFieldServer.
type InstallationRegistry ¶
type InstallationRegistry struct {
Installed map[string]InstalledPackage `yaml:"installed"`
}
InstallationRegistry mirrors the structure of installed.yaml
type InstalledPackage ¶
type InstalledPackage struct {
Name string `yaml:"name"`
Version string `yaml:"version"`
Description string `yaml:"description"`
Path string `yaml:"path"`
Source string `yaml:"source"`
SourcePath string `yaml:"source_path"`
InstalledAt string `yaml:"installed_at"`
Commit string `yaml:"commit"`
Ref string `yaml:"ref"`
AutoUpdate *bool `yaml:"auto_update"`
UpdatedAt string `yaml:"updated_at"`
Status string `yaml:"status"`
DesiredState string `yaml:"desired_state"`
Runtime struct {
Port int `yaml:"port"`
PID int `yaml:"pid"`
StartedAt string `yaml:"started_at"`
LogFile string `yaml:"log_file"`
BootID string `yaml:"boot_id"`
StartTime string `yaml:"start_time"`
} `yaml:"runtime"`
}