eventstore

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package eventstore provides append-only event streams with Server-Sent Events (SSE) support. It demonstrates all plugin API patterns: HTTP routes, database migrations, and background workers.

Events are stored in the event_stream table with tenant isolation. Each event is a JSONB blob with an auto-incrementing sequence number per (tenant, stream).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() plugin.Plugin

New creates a new Plugin instance.

Types

type Config

type Config struct {
	MaxEventSize  int `json:"max_event_size"` // max event body bytes; default 1 MB
	RetentionDays int `json:"retention_days"` // days to keep events; <=0 disables cleanup, default 30
}

Config controls eventstore parameters.

type Plugin

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

Plugin implements append-only event streams with tenant isolation.

func (*Plugin) Info

func (p *Plugin) Info() plugin.PluginInfo

Info returns plugin metadata for discovery and documentation.

func (*Plugin) Init

func (p *Plugin) Init(ctx context.Context, env *plugin.Environment) error

Init initializes the plugin with the given environment. It parses optional configuration and sets safe defaults for dev/testing.

func (*Plugin) Migrations

func (p *Plugin) Migrations() []plugin.Migration

Migrations returns the database schema for event streams. Tables are idempotent (IF NOT EXISTS) and safe to run multiple times.

func (*Plugin) RegisterRoutes

func (p *Plugin) RegisterRoutes(mux *http.ServeMux) error

func (*Plugin) Run

func (p *Plugin) Run(ctx context.Context) error

Run starts the periodic cleanup goroutine. It logs a cleanup message on a 1-hour ticker and respects context cancellation. Returns when ctx is done.

Jump to

Keyboard shortcuts

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