Documentation
¶
Overview ¶
Package plugin provides the public author API and runtime for executable bsbctl plugins. The normative wire and lifecycle contract is documented in docs/protocol/v1/spec.md and docs/plugin-authoring.md in the bsbctl module.
Index ¶
- Variables
- func IsPermanentConfiguration(err error) bool
- func PermanentConfiguration(err error) error
- func RejectSecrets(instanceID string, secrets map[string]string) error
- func Run(ctx context.Context, definition Definition) error
- type Contract
- type Definition
- type HealthReporter
- type Host
- func (h *Host) BeginSessionExecution(ctx context.Context, request protocol.SessionExecutionRequest) error
- func (h *Host) CompleteSession(ctx context.Context, request protocol.CompleteSessionRequest) error
- func (h *Host) Log(ctx context.Context, notification protocol.LogNotification) error
- func (h *Host) PublishObservation(ctx context.Context, value protocol.Observation) error
- func (h *Host) RecordMetric(notification protocol.MetricNotification) (bool, error)
- func (h *Host) SaveCheckpoint(ctx context.Context, request protocol.CheckpointRequest) error
- func (h *Host) WithdrawObservation(ctx context.Context, request protocol.WithdrawRequest) error
- type OperationHandler
- type Plugin
- type SessionHandler
- type Shutdowner
Constants ¶
This section is empty.
Variables ¶
var ErrPermanentConfiguration = errors.New("plugin configuration is permanently unavailable")
ErrPermanentConfiguration marks a replacement failure that cannot succeed until the executable or desired configuration changes.
Functions ¶
func IsPermanentConfiguration ¶
IsPermanentConfiguration reports whether err requires a configuration or executable change rather than a retry.
func PermanentConfiguration ¶
PermanentConfiguration wraps err as a permanent replacement failure.
func RejectSecrets ¶
RejectSecrets enforces the contract for plugins that declare no secret inputs. It deliberately omits secret names and values from the error.
Types ¶
type Contract ¶
type Contract struct {
ExecutionModes []protocol.ExecutionMode
Channels []protocol.Channel
Operations []protocol.OperationDescriptor
}
Contract is the immutable capability set returned during initialization.
type Definition ¶
Definition binds one immutable plugin identity and contract to its factory.
type HealthReporter ¶
type HealthReporter interface {
Health(context.Context) protocol.HealthResult
}
HealthReporter returns a current, UTC-stamped health result.
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
Host exposes daemon-owned effects. State-changing methods require a committed instance set and may return ErrorNotReady during replacement. BeginSessionExecution instead returns ErrorSessionGenerationMismatch. Log and RecordMetric remain available during initialization and replacement.
func (*Host) BeginSessionExecution ¶
func (h *Host) BeginSessionExecution(ctx context.Context, request protocol.SessionExecutionRequest) error
BeginSessionExecution obtains the daemon's final grant immediately before one irreversible effect owned by an exact foreground session.
func (*Host) CompleteSession ¶
CompleteSession reports that one exact interactive session has finished.
func (*Host) PublishObservation ¶
PublishObservation replaces one exact-generation observation after local and daemon validation.
func (*Host) RecordMetric ¶
func (h *Host) RecordMetric(notification protocol.MetricNotification) (bool, error)
RecordMetric attempts one validated lossy metric notification. accepted is false when the bounded transport queue drops it; callers should not spin.
func (*Host) SaveCheckpoint ¶
SaveCheckpoint durably replaces the bounded, non-secret checkpoint for one exact instance generation.
func (*Host) WithdrawObservation ¶
WithdrawObservation removes one exact-generation observation identity.
type OperationHandler ¶
type OperationHandler interface {
InvokeOperation(context.Context, protocol.OperationRequest) (protocol.OperationResult, error)
}
OperationHandler implements the immutable declared operation set.
type Plugin ¶
Plugin is the required lifecycle surface. ReplaceInstances receives the complete enabled desired set, is serialized with every other callback, and must replace prior state atomically or leave it unchanged on error.
type SessionHandler ¶
type SessionHandler interface {
StartSession(context.Context, protocol.SessionStartRequest) error
HandleSessionInput(context.Context, protocol.SessionInputRequest) (protocol.SessionInputResult, error)
EndSession(context.Context, protocol.SessionEndRequest) error
}
SessionHandler owns declared interactive sessions. EndSession must be idempotent for the exact instance generation and session token.
type Shutdowner ¶
Shutdowner releases plugin-owned workers and resources before its context expires. The runtime invokes it at most once.