eventstore

package
v0.13.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: 19 Imported by: 0

Documentation

Overview

Package eventstore is eventing's one durable store (ADR-0201): one Badger instance holding the Sensor's dead letters under dl/<ns>/<ulid> (ADR-0118), the BlobWatcher's seen lists under seen/ (ADR-0157) and the SQL change feed's watermarks under cdc/ (ADR-0235), each tenant iterating only its own prefix. With a directory both tenants survive a restart; in memory both are lost, and the seen lists live in a MemWatermark. The store is one ADR-0202 snapshot unit: Snapshot reads both tenants at once.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MigrateSeenLists

func MigrateSeenLists(ctx context.Context, kv kvstore.KV, s *Store) (moved int, err error)

MigrateSeenLists moves the seen lists the KV holds under legacyPrefix into s (ADR-0201 Decision 6). A record with no bucket (an ADR-0119 Cursor) is skipped, and one s already holds keeps the newer list s has. Every key under the prefix is deleted only after every copy committed, so an error leaves the KV keys and the next start resumes.

Types

type ChangeWatermarks added in v0.13.0

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

ChangeWatermarks keeps, per database and engine epoch, the highest Raft index the change feed published.

func (ChangeWatermarks) Delete added in v0.13.0

func (w ChangeWatermarks) Delete(_ context.Context, ns v1.NamespaceName, database v1.ObjectName) error

Delete drops every epoch's watermark of a deleted database.

func (ChangeWatermarks) Get added in v0.13.0

func (w ChangeWatermarks) Get(_ context.Context, ns v1.NamespaceName, database v1.ObjectName, epoch string) (uint64, error)

Get is the watermark of (ns, database, epoch); an unknown epoch is 0.

func (ChangeWatermarks) Set added in v0.13.0

func (w ChangeWatermarks) Set(_ context.Context, ns v1.NamespaceName, database v1.ObjectName, epoch string, index uint64) error

Set records index as the watermark of (ns, database, epoch).

type Config

type Config = dlbadger.Config

Config opens the store in memory (InMemory) or in an on-disk directory (Dir).

type Store

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

Store is the event store; DeadLetters and SeenLists are its two tenants.

func Open

func Open(cfg Config) (*Store, error)

Open opens the event store with the dead-letter profile, and runs the value-log GC on disk.

func (*Store) ChangeWatermarks added in v0.13.0

func (s *Store) ChangeWatermarks() ChangeWatermarks

ChangeWatermarks is the cdc/ tenant, in Badger in both modes, so the store's Snapshot and Load carry it.

func (*Store) Close

func (s *Store) Close() error

Close stops the GC loop, then closes the instance; the BlobWatcher and the Sensor must have stopped.

func (*Store) DeadLetters

func (s *Store) DeadLetters() deadletter.Store

DeadLetters is the dl/ tenant; its Close is a no-op, the store's Close closes the instance.

func (*Store) Load

func (s *Store) Load(ctx context.Context, next func() (snapshot.Record, error)) error

Load fills an empty store from a snapshot, before its views are used (ADR-0202 Loader); a store holding a dead letter or a seen list gets fault.Conflict before any write. In memory the seen/ records go to the MemWatermark.

func (*Store) SeenLists

func (s *Store) SeenLists() eventing.Watermark

SeenLists is the seen/ tenant: heads and parts on disk, a MemWatermark in memory.

func (*Store) Snapshot

func (s *Store) Snapshot(ctx context.Context, emit func(snapshot.Record) error) (string, error)

Snapshot emits both tenants in key order and returns "" (ADR-0202 Source). On disk it is one View; in memory the seen lists are copied under the MemWatermark's lock first, then follow the View's dead letters as gen-1 heads and parts, the layout a Load on disk reads back.

Jump to

Keyboard shortcuts

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