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

event

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package event defines sanitized v1 DTOs and bounded sink transport. It is not a usage store or a second event authority. Envelope, LimiterAdmission, ExtensionMutation, Sink, Publisher, Validate and Error are candidate protected surfaces. Registration, Options, Stats, Delivery, NewDelivery and Delivery.Publish/Flush/Close/Stats plus SchemaVersion and MaxEnvelopeBytes are also designated candidate transport surfaces. Released protection requires the enterprise extension contract's published-tag and consumer gates.

Index

Constants

View Source
const MaxEnvelopeBytes = 16 * 1024
View Source
const SchemaVersion = 1

Variables

This section is empty.

Functions

func Validate

func Validate(e Envelope, p attribution.Policy) error

Types

type Delivery

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

Delivery is a single worker owned by the existing gateway pipeline. Publish never waits for I/O. Sink callbacks execute serially; errors are never retried.

func NewDelivery

func NewDelivery(s Sink, o Options) (*Delivery, error)

func (*Delivery) Close

func (d *Delivery) Close(ctx context.Context) error

Close rejects new events immediately. The first call owns the shared shutdown budget; concurrent calls wait with their own (possibly shorter) deadline.

func (*Delivery) Flush

func (d *Delivery) Flush(ctx context.Context) error

Flush inserts a FIFO barrier and waits only for events accepted before it. It never calls the sink concurrently with Write or Close.

func (*Delivery) Publish

func (d *Delivery) Publish(ctx context.Context, e Envelope) bool

func (*Delivery) Stats

func (d *Delivery) Stats() Stats

type Envelope

type Envelope struct {
	SchemaVersion int                `json:"schema_version"`
	ID            string             `json:"event_id"`
	Family        string             `json:"family"`
	Timestamp     time.Time          `json:"timestamp"`
	Attribution   attribution.Value  `json:"attribution"`
	Outcome       string             `json:"outcome"`
	Reason        string             `json:"reason,omitempty"`
	Limiter       *LimiterAdmission  `json:"limiter_admission,omitempty"`
	Mutation      *ExtensionMutation `json:"extension_mutation,omitempty"`
}

type Error

type Error struct{ Code string }

func (*Error) Error

func (e *Error) Error() string

type ExtensionMutation

type ExtensionMutation struct {
	ModuleID   string `json:"module_id"`
	Operation  string `json:"operation"`
	StateReset bool   `json:"state_reset,omitempty"`
}

type LimiterAdmission

type LimiterAdmission struct {
	Dimension  string        `json:"dimension"`
	RetryAfter time.Duration `json:"retry_after_ns"`
	BackendID  string        `json:"backend_id"`
}

type Options

type Options struct {
	QueueSize   int
	WriteBudget time.Duration
	Policy      attribution.Policy
}

Options bounds one sink's transport. Zero values select the contract defaults. Policy must be the assembly-owned attribution allowlist.

type Publisher

type Publisher interface {
	Publish(context.Context, Envelope) bool
}

type Registration

type Registration struct {
	ModuleID    string
	New         func(context.Context) (Sink, error)
	QueueSize   int
	WriteBudget time.Duration
}

Registration is an explicit assembly-owned sink factory. New must honor its context and return a fresh sink per server lifecycle (including Caddy reload). ModuleID must name a linked descriptor. Callbacks never enter the manifest.

type Sink

type Sink interface {
	Write(context.Context, Envelope) error
	Flush(context.Context) error
	Close(context.Context) error
}

type Stats

type Stats struct {
	Accepted  uint64 `json:"accepted"`
	Delivered uint64 `json:"delivered"`
	Dropped   uint64 `json:"dropped"`
	Rejected  uint64 `json:"rejected"`
	Failures  uint64 `json:"failures"`
	Healthy   bool   `json:"healthy"`
}

Jump to

Keyboard shortcuts

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