export

package
v1.0.310 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 5 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 export is the additive, tenant-separated export foundation for the PR-8 event pipeline (MCP-EVENT-006 / MCP-PRIVACY-002). It provides an authorized tenant-scoped read over committed spool events, a pluggable Exporter interface (with deterministic test exporters — NO network SIEM client), a bounded worker Pump that drives export batches and advances an acknowledgment cursor, and the privacy guarantees:

  • external export failure NEVER erases local durability (the spool retains the record; the cursor only advances on a confirmed ack);
  • a read is authorized and tenant-separated: a tenant read returns ONLY that tenant's events, never another tenant's existence, count, range or content;
  • unattributed denial aggregates (no tenant) stay in an unattributed scope and are never returned to a tenant read;
  • everything is bounded (workers, batch records/bytes, retries, range).

This package adds no public HTTP API and reads no secret-bearing event form — every event it handles is already a safe envelope by construction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AckFunc

type AckFunc func(part model.Partition, throughSeq uint64)

AckFunc is called after a batch is acknowledged, with the highest sequence in the acknowledged prefix, so the caller can advance a durable cursor and mark segments exported (never before the ack).

type Authorization

type Authorization struct {
	Tenant     string // "" denotes the unattributed security scope (denial aggregates)
	Capability model.Capability
	Partitions map[model.Partition]bool
	MaxRecords int
	MaxBytes   int
}

Authorization is the trusted authorization context a read/export carries. It is supplied by an authenticated caller (a future Management API in PR-9), never by the requester's own claims. A read is refused unless the capability matches the reader, the partition is permitted, and the tenant scope is honored.

type Exporter

type Exporter interface {
	// Export durably delivers a bounded batch and returns the number accepted. A
	// returned error (or accepted < len(batch)) leaves the local records intact and
	// the cursor unadvanced past the accepted prefix.
	Export(ctx context.Context, batch []model.Event) (accepted int, err error)
}

Exporter is the pluggable additive sink. An implementation receives a bounded batch of safe events and returns an authenticated acknowledgment (how many it durably accepted). It is ADDITIVE: a failure here never erases local durability. PR-8 ships only deterministic in-memory exporters; a network SIEM/bus client is out of scope.

type Pump

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

Pump drives bounded export of one partition. It is single-worker by design (the manager runs a bounded pool of pumps); there is no per-event goroutine and no unbounded in-memory backlog — it reads a batch, exports it, advances the cursor only on ack, and stops on context cancel.

func NewPump

func NewPump(cfg PumpConfig, startCursor uint64) *Pump

NewPump builds a pump starting at cursor.

func (*Pump) Cursor

func (p *Pump) Cursor() uint64

Cursor returns the current acknowledged cursor.

func (*Pump) Step

func (p *Pump) Step(ctx context.Context) (int, error)

Step performs one bounded read→export→ack cycle. It returns the number of events exported this step (0 when nothing was pending) and an error. On an export error the cursor does NOT advance (local durability is preserved) and the error is returned after bounded retries. Step is what the manager's bounded worker loop calls; it never blocks indefinitely.

type PumpConfig

type PumpConfig struct {
	Reader     Reader
	Exporter   Exporter
	Limits     limits.EventLimits
	Auth       Authorization
	Partition  model.Partition
	BatchSize  int
	MaxRetries int
	OnAck      AckFunc
}

PumpConfig parameterises one bounded export pump.

type ReadResult

type ReadResult struct {
	Events     []model.Event
	NextCursor uint64
	More       bool
}

ReadResult is a bounded, tenant-scoped read.

func Read

func Read(r Reader, lim limits.EventLimits, auth Authorization, part model.Partition, afterSeq uint64) (ReadResult, error)

Read returns up to the authorized bound of a tenant's committed events from one partition, strictly after afterSeq. It enforces capability + partition scope and filters to the authorized tenant. Cross-tenant content is never returned: an event whose tenant differs from the authorization is dropped, and the unattributed (empty-tenant) denial aggregates are returned ONLY to the unattributed scope (Authorization.Tenant == "").

type Reader

type Reader interface {
	CommittedForExport(part model.Partition, afterSeq uint64, maxRecords int) ([]model.Event, []uint64, uint64, error)
	Capability() model.Capability
}

Reader is the spool-side committed-event source (implemented by *spool.Spool). CommittedForExport returns the events, their parallel sequences, and the scan cursor (highest sequence scanned).

Jump to

Keyboard shortcuts

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