plugin

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2026 License: GPL-3.0 Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

View Source
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

func IsPermanentConfiguration(err error) bool

IsPermanentConfiguration reports whether err requires a configuration or executable change rather than a retry.

func PermanentConfiguration

func PermanentConfiguration(err error) error

PermanentConfiguration wraps err as a permanent replacement failure.

func RejectSecrets

func RejectSecrets(instanceID string, secrets map[string]string) error

RejectSecrets enforces the contract for plugins that declare no secret inputs. It deliberately omits secret names and values from the error.

func Run

func Run(ctx context.Context, definition Definition) error

Run validates definition, serves the inherited private RPC socket, serializes callbacks, propagates cancellation and deadlines, and performs bounded shutdown when ctx ends or the daemon disconnects.

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

type Definition struct {
	ID       string
	Version  string
	Contract Contract
	New      func(*Host) Plugin
}

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

func (h *Host) CompleteSession(ctx context.Context, request protocol.CompleteSessionRequest) error

CompleteSession reports that one exact interactive session has finished.

func (*Host) Log

func (h *Host) Log(ctx context.Context, notification protocol.LogNotification) error

Log sends one validated structured diagnostic notification.

func (*Host) PublishObservation

func (h *Host) PublishObservation(ctx context.Context, value protocol.Observation) error

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

func (h *Host) SaveCheckpoint(ctx context.Context, request protocol.CheckpointRequest) error

SaveCheckpoint durably replaces the bounded, non-secret checkpoint for one exact instance generation.

func (*Host) WithdrawObservation

func (h *Host) WithdrawObservation(ctx context.Context, request protocol.WithdrawRequest) error

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

type Plugin interface {
	ReplaceInstances(context.Context, []protocol.Instance) error
}

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

SessionHandler owns declared interactive sessions. EndSession must be idempotent for the exact instance generation and session token.

type Shutdowner

type Shutdowner interface{ Shutdown(context.Context) error }

Shutdowner releases plugin-owned workers and resources before its context expires. The runtime invokes it at most once.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL