Documentation
¶
Overview ¶
Package pluginhost supervises direct-child executable plugins.
Index ¶
- Constants
- Variables
- func PermanentStart(err error) error
- type Callbacks
- type CheckpointRestore
- type Child
- type Clock
- type EndSessionRequest
- type Instance
- type InvocationKind
- type InvokeRequest
- type JitterFunc
- type Manager
- func (m *Manager) Apply(ctx context.Context, specs []Spec) error
- func (m *Manager) Changes() <-chan struct{}
- func (m *Manager) Close(ctx context.Context) error
- func (m *Manager) CompleteSession(ctx context.Context, pluginID string, request protocol.CompleteSessionRequest) error
- func (m *Manager) EndSession(ctx context.Context, pluginID string, target protocol.InstanceRef, ...) error
- func (m *Manager) Invoke(ctx context.Context, pluginID string, request InvokeRequest, ...) error
- func (m *Manager) Operation(ctx context.Context, pluginID string, request protocol.OperationRequest) (protocol.OperationResult, error)
- func (m *Manager) Restart(ctx context.Context, pluginID string) error
- func (m *Manager) SessionInputResult(ctx context.Context, pluginID string, request protocol.SessionInputRequest) (protocol.SessionInputResult, error)
- func (m *Manager) Status() []PluginStatus
- type ManagerOption
- type Phase
- type PluginStatus
- type Process
- func (p *Process) Done() <-chan error
- func (p *Process) EndSession(ctx context.Context, request EndSessionRequest) error
- func (p *Process) Invoke(ctx context.Context, request InvokeRequest) error
- func (p *Process) Operation(ctx context.Context, request protocol.OperationRequest) (protocol.OperationResult, error)
- func (p *Process) Ping(ctx context.Context) (protocol.HealthResult, error)
- func (p *Process) ReplaceInstances(ctx context.Context, instances []Instance) error
- func (p *Process) SessionInput(ctx context.Context, request protocol.SessionInputRequest) (protocol.SessionInputResult, error)
- func (p *Process) Stop(ctx context.Context) error
- type SessionCleanup
- type SessionInvalidation
- type SessionInvalidationReason
- type SessionToken
- type Spec
- type StartFunc
- type Timer
Constants ¶
const ( ErrorCodeStartFailed = "start_failed" ErrorCodeReconcileFailed = "reconcile_failed" ErrorCodeInvokeFailed = "invoke_failed" ErrorCodeEndSessionFailed = "end_session_failed" ErrorCodeSessionInputFailed = "session_input_failed" ErrorCodeOperationFailed = "operation_failed" ErrorCodeHealthTimeout = "health_timeout" ErrorCodeHealthReported = "health_reported_unhealthy" ErrorCodeUnexpectedExit = "unexpected_exit" ErrorCodeStopFailed = "stop_failed" ErrorCodeUnsupportedPlatform = "unsupported_platform" ErrorCodeConfigurationRejected = "configuration_rejected" )
Variables ¶
Functions ¶
func PermanentStart ¶
PermanentStart classifies a start failure that cannot recover until the executable or desired specification changes.
Types ¶
type Callbacks ¶
type Callbacks struct {
Observe func(observation.Source, protocol.Observation) error
Withdraw func(string, protocol.WithdrawRequest) error
WithdrawGeneration func(string, uint64)
WithdrawInstance func(string, string, uint64)
Checkpoint func(string, protocol.CheckpointRequest) error
CompleteSession func(context.Context, string, protocol.CompleteSessionRequest) error
BeginExecution func(context.Context, string, protocol.SessionExecutionRequest) error
SessionCompleted func(string, protocol.CompleteSessionRequest)
Metric func(protocol.MetricNotification)
Log func(string, protocol.LogNotification)
// SessionInvalidated is a short, non-blocking core hook for sessions that
// can no longer receive input from this package.
SessionInvalidated func(SessionInvalidation)
// SessionCleanup is a short, non-blocking core hook for stable cleanup
// lifecycle ownership outside the supervisor.
SessionCleanup func(SessionCleanup)
// Started is a non-blocking core hook called after a child handshake.
Started func(pluginID string, runID uint64)
}
Callbacks receive validated plugin effects.
type CheckpointRestore ¶
type CheckpointRestore struct {
Generation uint64
Data json.RawMessage
}
CheckpointRestore is a generation-scoped checkpoint supplied during desired instance replacement.
type Child ¶
type Child interface {
Invoke(context.Context, InvokeRequest) error
EndSession(context.Context, EndSessionRequest) error
ReplaceInstances(context.Context, []Instance) error
SessionInput(context.Context, protocol.SessionInputRequest) (protocol.SessionInputResult, error)
Operation(context.Context, protocol.OperationRequest) (protocol.OperationResult, error)
Ping(context.Context) (protocol.HealthResult, error)
Done() <-chan error
Stop(context.Context) error
}
type EndSessionRequest ¶
EndSessionRequest identifies one exact active plugin session.
type Instance ¶
type Instance struct {
ID string
Generation uint64
Config json.RawMessage
Secrets map[string]string
Policies map[string]presentation.PolicyConfig
Checkpoint *CheckpointRestore
}
Instance is one enabled desired plugin instance. Disabled configuration is excluded before it reaches the plugin host.
func (Instance) Ref ¶
func (instance Instance) Ref() protocol.InstanceRef
type InvocationKind ¶
type InvocationKind string
const (
InvocationInteractive InvocationKind = "interactive"
)
type InvokeRequest ¶
type InvokeRequest struct {
InstanceID string
Generation uint64
Action string
Payload json.RawMessage
SessionToken string
Trigger *protocol.SessionTrigger
}
InvokeRequest is the host's pre-dispatch session command.
type JitterFunc ¶
type JitterFunc func() float64
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager(coreVersion string, start StartFunc, callbacks Callbacks, optionValues ...ManagerOption) *Manager
func (*Manager) CompleteSession ¶
func (m *Manager) CompleteSession(ctx context.Context, pluginID string, request protocol.CompleteSessionRequest) error
CompleteSession releases the exact child-completed interactive session without sending a redundant end-session request back to that child.
func (*Manager) EndSession ¶
func (m *Manager) EndSession(ctx context.Context, pluginID string, target protocol.InstanceRef, token SessionToken) error
func (*Manager) Invoke ¶
func (m *Manager) Invoke(ctx context.Context, pluginID string, request InvokeRequest, kind InvocationKind, token SessionToken) error
func (*Manager) Operation ¶
func (m *Manager) Operation(ctx context.Context, pluginID string, request protocol.OperationRequest) (protocol.OperationResult, error)
func (*Manager) SessionInputResult ¶
func (m *Manager) SessionInputResult(ctx context.Context, pluginID string, request protocol.SessionInputRequest) (protocol.SessionInputResult, error)
func (*Manager) Status ¶
func (m *Manager) Status() []PluginStatus
type ManagerOption ¶
type ManagerOption func(*managerOptions)
func WithClock ¶
func WithClock(clock Clock) ManagerOption
func WithHealthInterval ¶
func WithHealthInterval(interval time.Duration) ManagerOption
func WithJitter ¶
func WithJitter(jitter JitterFunc) ManagerOption
type PluginStatus ¶
type PluginStatus struct {
ID string `json:"id"`
Desired bool `json:"desired"`
Phase Phase `json:"phase"`
Running bool `json:"running"`
Healthy bool `json:"healthy"`
HealthMisses int `json:"health_misses"`
ExitCount int `json:"exit_count"`
RetryAt time.Time `json:"retry_at,omitempty"`
LastErrorCode string `json:"last_error_code,omitempty"`
LastErrorAt time.Time `json:"last_error_at,omitempty"`
SessionLifecycleErrorCode string `json:"session_lifecycle_error_code,omitempty"`
SessionLifecycleErrorAt time.Time `json:"session_lifecycle_error_at,omitempty"`
}
type Process ¶
type Process struct {
// contains filtered or unexported fields
}
Process owns one direct child, its process group, RPC connection, and Wait call.
func Start ¶
func Start(ctx context.Context, coreVersion string, spec Spec, callbacks Callbacks) (*Process, error)
Start verifies and starts a direct child, then completes the identity handshake.
func (*Process) EndSession ¶
func (p *Process) EndSession(ctx context.Context, request EndSessionRequest) error
EndSession tells the plugin that one interactive instance session has ended.
func (*Process) Operation ¶
func (p *Process) Operation(ctx context.Context, request protocol.OperationRequest) (protocol.OperationResult, error)
func (*Process) ReplaceInstances ¶
ReplaceInstances atomically supplies the plugin's complete desired state.
func (*Process) SessionInput ¶
func (p *Process) SessionInput(ctx context.Context, request protocol.SessionInputRequest) (protocol.SessionInputResult, error)
SessionInput delivers one exact interactive input and returns the plugin's strict consumed/not-consumed disposition.
type SessionCleanup ¶
type SessionCleanup struct {
PluginID string
Sequence uint64
At time.Time
PendingCount int
ErrorCode string
}
SessionCleanup reports supervisor-owned session cleanup lifecycle state. PluginID is assigned by the authenticated supervisor, never by a child.
type SessionInvalidation ¶
type SessionInvalidation struct {
PluginID string
InstanceID string
Generation uint64
Token SessionToken
Reason SessionInvalidationReason
}
type SessionInvalidationReason ¶
type SessionInvalidationReason string
const ( SessionInvalidatedExit SessionInvalidationReason = "child_exit" SessionInvalidatedHealth SessionInvalidationReason = "health_failure" SessionInvalidatedDisabled SessionInvalidationReason = "disabled" SessionInvalidatedGeneration SessionInvalidationReason = "generation_changed" SessionInvalidatedReplaced SessionInvalidationReason = "child_replaced" SessionInvalidatedInput SessionInvalidationReason = "session_input_failed" )
type SessionToken ¶
type SessionToken string
type Spec ¶
type Spec struct {
ID string
Version string
Executable string
Args []string
SHA256 string
ProtocolVersion string
ExecutionModes []protocol.ExecutionMode
Channels []protocol.Channel
Operations []protocol.OperationDescriptor
Instances []Instance
}
Spec is one verified plugin executable and its current enabled instances.