eventstore

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 18 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) and the BlobWatcher's seen lists under seen/ (ADR-0157), 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 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) 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