delivery

package
v0.16.5 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: BSD-3-Clause, GPL-3.0 Imports: 17 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

Overview

Package delivery provides opt-in, at-least-once webhook delivery. Receivers must deduplicate Idempotency-Key; a crash after acceptance can repeat a POST.

Index

Constants

View Source
const MaxEntries = 10000

Variables

View Source
var ErrFull = errors.New("alert outbox capacity reached (including idempotency receipts)")

Functions

This section is empty.

Types

type AlertWriter

type AlertWriter interface {
	WriteAlert(*types.Alert) error
	Close() error
}

type Notice

type Notice struct {
	Version      string `json:"version"`
	Scope        string `json:"scope"`
	Timestamp    int64  `json:"timestamp,string"`
	Rule         string `json:"rule"`
	Severity     string `json:"severity"`
	RecordType   string `json:"recordType"`
	RuleDigest   string `json:"ruleDigest"`
	RecordDigest string `json:"recordDigest"`
	SrcIP        string `json:"srcIP"`
	DstIP        string `json:"dstIP"`
}

Notice intentionally excludes raw records, expressions, notes, descriptions, tags and authentication material. Scope is supplied by the capture owner.

type Outbox

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

func Open

func Open(directory, endpoint string) (*Outbox, error)

Open pins a private database to one destination. Credentials belong in the runtime request header, never the URL or persisted queue. No worker is spawned.

func (*Outbox) Close

func (o *Outbox) Close() error

func (*Outbox) Deliver

func (o *Outbox) Deliver(ctx context.Context, limit int, token string) error

Deliver attempts at most limit currently-due notices, serially. Retry delays are persisted (1s exponential backoff, capped at 1h). 408/425/429/5xx and transport errors retry; other non-2xx responses retain rejected receipts. token is read by the caller at runtime and is never stored or returned.

func (*Outbox) Enqueue

func (o *Outbox) Enqueue(scope string, a *types.Alert) (string, error)

Enqueue commits before returning. Identical semantic notices reuse one durable receipt even after delivery/restart. Full queues fail rather than lose evidence.

func (*Outbox) Status

func (o *Outbox) Status() (Status, error)

type Status

type Status struct {
	Pending   int `json:"pending"`
	Delivered int `json:"delivered"`
	Rejected  int `json:"rejected"`
}

func (Status) RequireDrained

func (s Status) RequireDrained() error

RequireDrained distinguishes a persisted retry backlog from delivery success.

type Writer

type Writer struct {
	Audit  AlertWriter
	Outbox *Outbox
	Scope  string
}

Writer retains the audit first, then commits a redacted delivery notice. A failed enqueue returns an error; the durable audit can be re-enqueued later. Close does not deliver or discard pending notices and does not own the outbox.

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) WriteAlert

func (w *Writer) WriteAlert(a *types.Alert) error

Jump to

Keyboard shortcuts

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