module

package
v2.15.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 9 Imported by: 0 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgePruner added in v2.11.0

type AgePruner interface {
	PruneBefore(ctx context.Context, cutoff time.Time) (int, error)
}

AgePruner is an optional Module add-on for modules that keep rows with no event card (Sentry logs, metrics, traces). Retention with max_age calls it to delete those rows older than cutoff; it returns how many it deleted.

type BaseModule

type BaseModule struct{}

BaseModule provides no-op defaults for optional Module methods.

func (BaseModule) HTTPHandler

func (b BaseModule) HTTPHandler() HTTPIngestionHandler

func (BaseModule) OnEventStored

func (b BaseModule) OnEventStored(_ event.Event)

func (BaseModule) OnInit

func (b BaseModule) OnInit(_ *sql.DB) error

func (BaseModule) PreviewMapper

func (b BaseModule) PreviewMapper() event.PreviewMapper

func (BaseModule) RegisterMigrations

func (b BaseModule) RegisterMigrations(_ *storage.Migrator) error

func (BaseModule) RegisterRoutes

func (b BaseModule) RegisterRoutes(_ *http.ServeMux, _ event.Store)

func (BaseModule) TCPServers

func (b BaseModule) TCPServers() []tcp.ServerConfig

type Broadcaster

type Broadcaster interface {
	Broadcast(channel, eventName string, payload any)
}

Broadcaster publishes an event on a WebSocket channel: the ws.Hub.

type Broadcasting

type Broadcasting interface {
	SetBroadcaster(b Broadcaster)
}

Broadcasting is implemented by a module that sends notices of its own to the browser, beside the events it stores through the EventService - for example that it stored rows that create no feed card. It is optional: WireBroadcaster hands every module that implements it the hub at startup.

type EventDeleteListener

type EventDeleteListener interface {
	OnEventsDeleted(uuids []string)
}

EventDeleteListener is an optional Module add-on for modules that keep data outside the events table (files, side tables). It is called after events were removed by a single delete, a clear-all or a batch delete.

type HTTPIngestionHandler

type HTTPIngestionHandler interface {
	// Priority determines ordering. Lower runs first. HttpDumps = 9999.
	Priority() int

	// Match returns true if this module should handle the request.
	Match(r *http.Request) bool

	// Handle processes the request and returns the event to store.
	Handle(r *http.Request) (*event.Incoming, error)
}

HTTPIngestionHandler decides if an HTTP request belongs to a module.

type Module

type Module interface {
	// Name returns a human-readable module name (e.g., "Sentry").
	Name() string

	// Type returns the event type string stored in the events table.
	Type() string

	// RegisterRoutes adds module-specific API routes to the router.
	RegisterRoutes(mux *http.ServeMux, store event.Store)

	// HTTPHandler returns a handler that inspects an incoming request
	// and either claims it or returns nil. Return nil if this module
	// has no HTTP ingestion (e.g., TCP-only modules).
	HTTPHandler() HTTPIngestionHandler

	// TCPServers returns TCP server configurations this module needs.
	TCPServers() []tcp.ServerConfig

	// PreviewMapper returns the mapper for converting payloads to previews.
	PreviewMapper() event.PreviewMapper

	// RegisterMigrations registers module-specific SQL migration files.
	RegisterMigrations(migrator *storage.Migrator) error

	// OnInit is called once at startup after migrations are applied.
	OnInit(db *sql.DB) error

	// OnEventStored is called after any event is persisted.
	OnEventStored(ev event.Event)
}

Module is the interface every event module must implement. Embed BaseModule to get no-op defaults for optional methods.

type ProtectedRoutesRegistrar

type ProtectedRoutesRegistrar interface {
	RegisterProtectedRoutes(mux *http.ServeMux, protect func(http.Handler) http.Handler)
}

ProtectedRoutesRegistrar is an optional Module add-on for API routes that must sit behind the API's auth middleware. It is called after the middleware is built, unlike RegisterRoutes.

type Registry

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

Registry collects modules and provides access to their handlers.

func NewRegistry

func NewRegistry() *Registry

func (*Registry) AgePruners added in v2.11.0

func (r *Registry) AgePruners() []AgePruner

AgePruners returns the modules that implement AgePruner.

func (*Registry) Handlers

func (r *Registry) Handlers() []HTTPIngestionHandler

Handlers returns HTTP ingestion handlers sorted by priority.

func (*Registry) Init

func (r *Registry) Init(db *sql.DB, mux *http.ServeMux, store event.Store) error

Init initializes all modules: runs migrations, routes, handlers.

func (*Registry) Modules

func (r *Registry) Modules() []Module

Modules returns the registered modules in registration order.

func (*Registry) NotifyEventStored

func (r *Registry) NotifyEventStored(ev event.Event)

NotifyEventStored calls OnEventStored on all modules.

func (*Registry) NotifyEventsDeleted

func (r *Registry) NotifyEventsDeleted(uuids []string)

NotifyEventsDeleted calls OnEventsDeleted on modules that implement EventDeleteListener.

func (*Registry) Previews

func (r *Registry) Previews() *event.PreviewRegistry

Previews returns the preview registry.

func (*Registry) Register

func (r *Registry) Register(m Module)

Register adds a module to the registry.

func (*Registry) RegisterProtectedRoutes

func (r *Registry) RegisterProtectedRoutes(mux *http.ServeMux, protect func(http.Handler) http.Handler)

RegisterProtectedRoutes lets modules that implement ProtectedRoutesRegistrar add their API routes behind protect.

func (*Registry) TCPServers

func (r *Registry) TCPServers() []tcp.ServerConfig

TCPServers returns all TCP server configs from all modules.

func (*Registry) WireBroadcaster

func (r *Registry) WireBroadcaster(b Broadcaster)

WireBroadcaster gives the broadcaster to every registered module that implements Broadcasting.

Jump to

Keyboard shortcuts

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