Documentation
¶
Overview ¶
Package supervisor owns the lifecycle of one controller's session workers.
It is the only place a worker is created, so the profile policy cannot be bypassed, no worker runs without a durable generation row, and no worker is accepted without the credential this controller issued for that exact generation.
Index ¶
- type EnsureRequest
- type Options
- type Supervisor
- func (s *Supervisor) AcceptWorker(ctx context.Context, hello protocol.Hello) (protocol.HelloAck, error)
- func (s *Supervisor) Current(sessionID uuid.UUID) (*protocol.Worker, bool)
- func (s *Supervisor) Ensure(ctx context.Context, request EnsureRequest) (*protocol.Worker, error)
- func (s *Supervisor) EnsureSessionWorker(ctx context.Context, sessionID uuid.UUID, workspace string, profileName string) (*protocol.Worker, error)
- func (s *Supervisor) Profiles() *worker.ProfileSet
- func (s *Supervisor) Stop(ctx context.Context, sessionID uuid.UUID) error
- func (s *Supervisor) StopAll(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EnsureRequest ¶
EnsureRequest asks for one session's live worker.
type Options ¶
type Options struct {
Store *session.Store
Profiles *worker.ProfileSet
// Launchers holds one launcher per kind. A kind with no launcher cannot
// run: a Docker profile on a controller with no Docker socket is refused
// rather than run somewhere else.
Launchers map[worker.Kind]worker.Launcher
// Publisher receives durable records after the controller writes them.
Publisher protocol.Publisher
// SocketRoot is the controller's private worker socket directory. It is
// separate from the SQLite directory and from the public API.
SocketRoot string
// ConfigDirectory is the global Peen configuration every worker reads.
ConfigDirectory string
ReadyTimeout time.Duration
StopTimeout time.Duration
}
Options builds a supervisor.
type Supervisor ¶
type Supervisor struct {
// contains filtered or unexported fields
}
Supervisor holds one live worker per session.
func New ¶
func New(options Options) (*Supervisor, error)
New validates the supervisor's dependencies.
func (*Supervisor) AcceptWorker ¶
func (s *Supervisor) AcceptWorker( ctx context.Context, hello protocol.Hello, ) (protocol.HelloAck, error)
AcceptWorker verifies one registration against the durable generation.
A worker is accepted only when this controller recorded that session, that generation, and that credential hash, and the generation has not already ended. It is what stops a worker replaying another generation's credential.
func (*Supervisor) Ensure ¶
func (s *Supervisor) Ensure( ctx context.Context, request EnsureRequest, ) (*protocol.Worker, error)
Ensure returns the session's registered worker, launching one when the session has none.
A session keeps its worker across turns. A worker whose connection ended is replaced by a new generation rather than reused, and the replacement is recorded before it runs.
func (*Supervisor) EnsureSessionWorker ¶
func (s *Supervisor) EnsureSessionWorker( ctx context.Context, sessionID uuid.UUID, workspace string, profileName string, ) (*protocol.Worker, error)
EnsureSessionWorker is Ensure in the shape the control surface routes with.
The workspace and profile come from the stored session, so a client naming a session cannot also choose where it runs or what it may do.
func (*Supervisor) Profiles ¶
func (s *Supervisor) Profiles() *worker.ProfileSet
Profiles exposes the deployment's allowed profiles for reporting.