plugin

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package plugin defines the plugin system for CtrlPlane.

Plugins are notified of lifecycle events (instance created, deploy started, health check failed, etc.) and can react to them — logging, metrics, tracing, auditing, etc.

Each lifecycle hook is a separate interface so plugins opt in only to the events they care about.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertExpiring

type CertExpiring interface {
	OnCertExpiring(ctx context.Context, evt *event.Event) error
}

CertExpiring is called when a TLS certificate is approaching expiry.

type CertProvisioned

type CertProvisioned interface {
	OnCertProvisioned(ctx context.Context, evt *event.Event) error
}

CertProvisioned is called when a TLS certificate is provisioned.

type DeployFailed

type DeployFailed interface {
	OnDeployFailed(ctx context.Context, evt *event.Event) error
}

DeployFailed is called when a deployment fails.

type DeployRolledBack

type DeployRolledBack interface {
	OnDeployRolledBack(ctx context.Context, evt *event.Event) error
}

DeployRolledBack is called when a deployment is rolled back.

type DeployStarted

type DeployStarted interface {
	OnDeployStarted(ctx context.Context, evt *event.Event) error
}

DeployStarted is called when a deployment begins.

type DeploySucceeded

type DeploySucceeded interface {
	OnDeploySucceeded(ctx context.Context, evt *event.Event) error
}

DeploySucceeded is called when a deployment completes successfully.

type DomainAdded

type DomainAdded interface {
	OnDomainAdded(ctx context.Context, evt *event.Event) error
}

DomainAdded is called when a domain is added to an instance.

type DomainRemoved

type DomainRemoved interface {
	OnDomainRemoved(ctx context.Context, evt *event.Event) error
}

DomainRemoved is called when a domain is removed.

type DomainVerified

type DomainVerified interface {
	OnDomainVerified(ctx context.Context, evt *event.Event) error
}

DomainVerified is called when a domain passes verification.

type Extension

type Extension interface {
	// Name returns a unique human-readable name for the plugin.
	Name() string
}

Extension is the base interface all CtrlPlane plugins must implement.

type HealthCheckFailed

type HealthCheckFailed interface {
	OnHealthCheckFailed(ctx context.Context, evt *event.Event) error
}

HealthCheckFailed is called when a health check fails.

type HealthCheckPassed

type HealthCheckPassed interface {
	OnHealthCheckPassed(ctx context.Context, evt *event.Event) error
}

HealthCheckPassed is called when a health check passes.

type HealthDegraded

type HealthDegraded interface {
	OnHealthDegraded(ctx context.Context, evt *event.Event) error
}

HealthDegraded is called when an instance enters a degraded state.

type HealthRecovered

type HealthRecovered interface {
	OnHealthRecovered(ctx context.Context, evt *event.Event) error
}

HealthRecovered is called when an instance recovers from a degraded state.

type InstanceCreated

type InstanceCreated interface {
	OnInstanceCreated(ctx context.Context, evt *event.Event) error
}

InstanceCreated is called when an instance is provisioned.

type InstanceDeleted

type InstanceDeleted interface {
	OnInstanceDeleted(ctx context.Context, evt *event.Event) error
}

InstanceDeleted is called when an instance is deprovisioned and removed.

type InstanceFailed

type InstanceFailed interface {
	OnInstanceFailed(ctx context.Context, evt *event.Event) error
}

InstanceFailed is called when an instance enters a failed state.

type InstanceScaled

type InstanceScaled interface {
	OnInstanceScaled(ctx context.Context, evt *event.Event) error
}

InstanceScaled is called when instance resources are adjusted.

type InstanceStarted

type InstanceStarted interface {
	OnInstanceStarted(ctx context.Context, evt *event.Event) error
}

InstanceStarted is called when an instance transitions to running.

type InstanceStopped

type InstanceStopped interface {
	OnInstanceStopped(ctx context.Context, evt *event.Event) error
}

InstanceStopped is called when an instance is stopped.

type InstanceSuspended

type InstanceSuspended interface {
	OnInstanceSuspended(ctx context.Context, evt *event.Event) error
}

InstanceSuspended is called when an instance is suspended.

type InstanceUnsuspended

type InstanceUnsuspended interface {
	OnInstanceUnsuspended(ctx context.Context, evt *event.Event) error
}

InstanceUnsuspended is called when a suspended instance is restored.

type QuotaExceeded

type QuotaExceeded interface {
	OnQuotaExceeded(ctx context.Context, evt *event.Event) error
}

QuotaExceeded is called when a tenant exceeds their quota.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry holds registered plugins and dispatches lifecycle events to them. It type-caches plugins at registration time so emit calls iterate only over plugins that implement the relevant hook.

func NewRegistry

func NewRegistry(logger *slog.Logger) *Registry

NewRegistry creates a plugin registry with the given logger.

func (*Registry) EmitCertExpiring

func (r *Registry) EmitCertExpiring(ctx context.Context, evt *event.Event)

EmitCertExpiring notifies all plugins that implement CertExpiring.

func (*Registry) EmitCertProvisioned

func (r *Registry) EmitCertProvisioned(ctx context.Context, evt *event.Event)

EmitCertProvisioned notifies all plugins that implement CertProvisioned.

func (*Registry) EmitDeployFailed

func (r *Registry) EmitDeployFailed(ctx context.Context, evt *event.Event)

EmitDeployFailed notifies all plugins that implement DeployFailed.

func (*Registry) EmitDeployRolledBack

func (r *Registry) EmitDeployRolledBack(ctx context.Context, evt *event.Event)

EmitDeployRolledBack notifies all plugins that implement DeployRolledBack.

func (*Registry) EmitDeployStarted

func (r *Registry) EmitDeployStarted(ctx context.Context, evt *event.Event)

EmitDeployStarted notifies all plugins that implement DeployStarted.

func (*Registry) EmitDeploySucceeded

func (r *Registry) EmitDeploySucceeded(ctx context.Context, evt *event.Event)

EmitDeploySucceeded notifies all plugins that implement DeploySucceeded.

func (*Registry) EmitDomainAdded

func (r *Registry) EmitDomainAdded(ctx context.Context, evt *event.Event)

EmitDomainAdded notifies all plugins that implement DomainAdded.

func (*Registry) EmitDomainRemoved

func (r *Registry) EmitDomainRemoved(ctx context.Context, evt *event.Event)

EmitDomainRemoved notifies all plugins that implement DomainRemoved.

func (*Registry) EmitDomainVerified

func (r *Registry) EmitDomainVerified(ctx context.Context, evt *event.Event)

EmitDomainVerified notifies all plugins that implement DomainVerified.

func (*Registry) EmitHealthCheckFailed

func (r *Registry) EmitHealthCheckFailed(ctx context.Context, evt *event.Event)

EmitHealthCheckFailed notifies all plugins that implement HealthCheckFailed.

func (*Registry) EmitHealthCheckPassed

func (r *Registry) EmitHealthCheckPassed(ctx context.Context, evt *event.Event)

EmitHealthCheckPassed notifies all plugins that implement HealthCheckPassed.

func (*Registry) EmitHealthDegraded

func (r *Registry) EmitHealthDegraded(ctx context.Context, evt *event.Event)

EmitHealthDegraded notifies all plugins that implement HealthDegraded.

func (*Registry) EmitHealthRecovered

func (r *Registry) EmitHealthRecovered(ctx context.Context, evt *event.Event)

EmitHealthRecovered notifies all plugins that implement HealthRecovered.

func (*Registry) EmitInstanceCreated

func (r *Registry) EmitInstanceCreated(ctx context.Context, evt *event.Event)

EmitInstanceCreated notifies all plugins that implement InstanceCreated.

func (*Registry) EmitInstanceDeleted

func (r *Registry) EmitInstanceDeleted(ctx context.Context, evt *event.Event)

EmitInstanceDeleted notifies all plugins that implement InstanceDeleted.

func (*Registry) EmitInstanceFailed

func (r *Registry) EmitInstanceFailed(ctx context.Context, evt *event.Event)

EmitInstanceFailed notifies all plugins that implement InstanceFailed.

func (*Registry) EmitInstanceScaled

func (r *Registry) EmitInstanceScaled(ctx context.Context, evt *event.Event)

EmitInstanceScaled notifies all plugins that implement InstanceScaled.

func (*Registry) EmitInstanceStarted

func (r *Registry) EmitInstanceStarted(ctx context.Context, evt *event.Event)

EmitInstanceStarted notifies all plugins that implement InstanceStarted.

func (*Registry) EmitInstanceStopped

func (r *Registry) EmitInstanceStopped(ctx context.Context, evt *event.Event)

EmitInstanceStopped notifies all plugins that implement InstanceStopped.

func (*Registry) EmitInstanceSuspended

func (r *Registry) EmitInstanceSuspended(ctx context.Context, evt *event.Event)

EmitInstanceSuspended notifies all plugins that implement InstanceSuspended.

func (*Registry) EmitInstanceUnsuspended

func (r *Registry) EmitInstanceUnsuspended(ctx context.Context, evt *event.Event)

EmitInstanceUnsuspended notifies all plugins that implement InstanceUnsuspended.

func (*Registry) EmitQuotaExceeded

func (r *Registry) EmitQuotaExceeded(ctx context.Context, evt *event.Event)

EmitQuotaExceeded notifies all plugins that implement QuotaExceeded.

func (*Registry) EmitShutdown

func (r *Registry) EmitShutdown(ctx context.Context)

EmitShutdown notifies all plugins that implement Shutdown.

func (*Registry) EmitTenantCreated

func (r *Registry) EmitTenantCreated(ctx context.Context, evt *event.Event)

EmitTenantCreated notifies all plugins that implement TenantCreated.

func (*Registry) EmitTenantDeleted

func (r *Registry) EmitTenantDeleted(ctx context.Context, evt *event.Event)

EmitTenantDeleted notifies all plugins that implement TenantDeleted.

func (*Registry) EmitTenantSuspended

func (r *Registry) EmitTenantSuspended(ctx context.Context, evt *event.Event)

EmitTenantSuspended notifies all plugins that implement TenantSuspended.

func (*Registry) Extensions

func (r *Registry) Extensions() []Extension

Extensions returns all registered plugins.

func (*Registry) HandleEvent

func (r *Registry) HandleEvent(ctx context.Context, evt *event.Event) error

HandleEvent is the event bus handler. It dispatches an event.Event to the appropriate plugin hook(s) based on the event type. This method is subscribed to the event bus to bridge events to plugins.

func (*Registry) Register

func (r *Registry) Register(e Extension)

Register adds a plugin and type-asserts it into all applicable hook caches. Plugins are notified in registration order.

type Shutdown

type Shutdown interface {
	OnShutdown(ctx context.Context) error
}

Shutdown is called during graceful shutdown.

type TenantCreated

type TenantCreated interface {
	OnTenantCreated(ctx context.Context, evt *event.Event) error
}

TenantCreated is called when a new tenant is created.

type TenantDeleted

type TenantDeleted interface {
	OnTenantDeleted(ctx context.Context, evt *event.Event) error
}

TenantDeleted is called when a tenant is deleted.

type TenantSuspended

type TenantSuspended interface {
	OnTenantSuspended(ctx context.Context, evt *event.Event) error
}

TenantSuspended is called when a tenant is suspended.

Jump to

Keyboard shortcuts

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