Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrRestartRequested = errors.New("agent restart requested")
ErrRestartRequested is returned by a command handler to signal that the agent should restart itself after sending a success result to the panel.
Functions ¶
Types ¶
type Client ¶
type Client struct {
URL string
Token string
Name string
Version string
HeartbeatInterval time.Duration
ReconnectDelay time.Duration
Executor *Executor
AllowedScopes []string // nil = all scopes; sent in hello/heartbeat so the panel knows
// contains filtered or unexported fields
}
Client connects to a zeus web panel, authenticates with a token, and dispatches incoming commands to the Executor. It reconnects automatically on disconnect.
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor is a registry of command handlers. It is safe for concurrent use.
func NewExecutor ¶
func NewExecutor() *Executor
func (*Executor) Dispatch ¶
func (e *Executor) Dispatch(ctx context.Context, cmd string, args map[string]any, w io.Writer) error
Dispatch looks up the handler for cmd and runs it. Returns an error if the command is unknown, not in the allowed set, or the handler fails.
func (*Executor) Register ¶
func (e *Executor) Register(cmd string, h HandlerFunc)
Register associates a command name with a handler. Calling Register twice for the same name replaces the previous handler.
func (*Executor) SetAllowed ¶
SetAllowed restricts dispatch to the given command set. Pass nil to remove restrictions (allow all).
type HandlerFunc ¶
HandlerFunc is the signature every command handler must implement. args mirrors the Command.Args map from the protocol envelope. w receives all output lines that will be streamed back to the server.
type StatusFunc ¶
type StatusFunc func() []protocol.ProfileStatus
StatusFunc returns the current running state of all profiles. Client calls it for each heartbeat.