Help us shape the future of Go! Take the 2026 Go Developer Survey

plugin

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package plugin provides the extensibility system for Chronicle. Plugins implement subsets of discovery-based interfaces. Chronicle discovers which interfaces a plugin implements at registration time and caches the dispatch paths for O(1) per-event overhead.

Index

Constants

This section is empty.

Variables

View Source
var ErrSkipEvent = errors.New("chronicle: skip event")

ErrSkipEvent is returned by BeforeRecord plugins to skip recording an event.

Functions

This section is empty.

Types

type AfterRecord

type AfterRecord interface {
	OnAfterRecord(ctx context.Context, event *audit.Event) error
}

AfterRecord fires AFTER an event is successfully persisted to the store. Use for notifications, alerts, forwarding.

type AlertHandler

type AlertHandler interface {
	OnAlert(ctx context.Context, event *audit.Event, rule *AlertRule) error
}

AlertHandler fires when an event matches alert criteria.

type AlertRule

type AlertRule struct {
	Severity string `json:"severity,omitempty"`
	Category string `json:"category,omitempty"`
	Action   string `json:"action,omitempty"`
	Outcome  string `json:"outcome,omitempty"`
}

AlertRule defines criteria for triggering alerts.

type BeforeRecord

type BeforeRecord interface {
	OnBeforeRecord(ctx context.Context, event *audit.Event) error
}

BeforeRecord fires BEFORE an event is persisted. Use for enrichment (add metadata), filtering (return ErrSkipEvent), or transformation.

type ComplianceReporter

type ComplianceReporter interface {
	ReportType() string
}

ComplianceReporter provides a custom compliance report type.

type Exporter

type Exporter interface {
	Format() string
	Export(ctx context.Context, data any, w io.Writer) error
}

Exporter provides a custom export format.

type OnInit

type OnInit interface {
	OnInit(ctx context.Context) error
}

OnInit is called when Chronicle starts.

type OnShutdown

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

OnShutdown is called when Chronicle stops.

type Plugin

type Plugin interface {
	Name() string
}

Plugin is the primary extensibility point for Chronicle. Implement any subset of the hook interfaces below.

type Registry

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

Registry manages plugins and dispatches hook calls.

func NewRegistry

func NewRegistry(logger log.Logger) *Registry

NewRegistry creates a new plugin Registry.

func (*Registry) EmitAfterRecord

func (r *Registry) EmitAfterRecord(ctx context.Context, event *audit.Event)

EmitAfterRecord calls OnAfterRecord on all registered plugins. Errors are logged but do not block the pipeline.

func (*Registry) EmitBeforeRecord

func (r *Registry) EmitBeforeRecord(ctx context.Context, event *audit.Event) error

EmitBeforeRecord calls OnBeforeRecord on all registered plugins. Returns ErrSkipEvent if any plugin returns it. Other errors are logged but do not block the pipeline.

func (*Registry) EmitInit

func (r *Registry) EmitInit(ctx context.Context) error

EmitInit calls OnInit on all registered plugins.

func (*Registry) EmitShutdown

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

EmitShutdown calls OnShutdown on all registered plugins.

func (*Registry) Plugins

func (r *Registry) Plugins() []Plugin

Plugins returns all registered plugins.

func (*Registry) Register

func (r *Registry) Register(p Plugin)

Register adds a plugin and discovers its hook implementations.

func (*Registry) SetAlertRules

func (r *Registry) SetAlertRules(rules []AlertRule)

SetAlertRules sets the alert rules for matching events.

func (*Registry) Sinks

func (r *Registry) Sinks() []sink.Sink

Sinks returns all sinks provided by registered plugins.

type SinkProvider

type SinkProvider interface {
	Sink() sink.Sink
}

SinkProvider provides a custom sink to be added to the sink fan-out.

Jump to

Keyboard shortcuts

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