wal

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Commit

type Commit func() error

Commit drops a logged event once its operation has succeeded.

type EventHandler

type EventHandler interface {
	Typ() string
	Encode(any) ([]byte, error)
	Decode([]byte) (any, error)
	Handle(context.Context, any) error
}

type Hydro

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

Hydro journals events into the eru store, under the prefix of this instance's service address.

func NewHydro

func NewHydro(ctx context.Context, store Store, address string, config coretypes.Config) (*Hydro, error)

func (*Hydro) Log

func (h *Hydro) Log(eventyp string, item any) (Commit, error)

func (*Hydro) Recover

func (h *Hydro) Recover(ctx context.Context)

func (*Hydro) Register

func (h *Hydro) Register(handler EventHandler)

func (*Hydro) Takeover added in v0.1.1

func (h *Hydro) Takeover(ctx context.Context, live []string)

Takeover replays the journals of instances no longer registered as live; a nil live set means nothing is known yet.

type HydroEvent

type HydroEvent struct {
	Type string `json:"type"`
	Item []byte `json:"item"`
}

HydroEvent is one journal entry: what happened and the handler's own payload.

func NewHydroEvent

func NewHydroEvent(typ string, item []byte) *HydroEvent

func (HydroEvent) Encode

func (e HydroEvent) Encode() ([]byte, error)

type Store added in v0.1.1

type Store interface {
	Put(ctx context.Context, data map[string]string) error
	Delete(ctx context.Context, keys []string) error
	GetPrefix(ctx context.Context, prefix string, limit int64) (map[string]string, error)
	ListPrefix(ctx context.Context, prefix string) ([]string, error)
	CreateLock(key string, ttl time.Duration) (lock.DistributedLock, error)
}

Store is the part of the eru store a journal writes through.

type WAL

type WAL interface {
	Register(EventHandler)
	Recover(context.Context)
	Takeover(ctx context.Context, live []string)
	Log(string, any) (Commit, error)
}

WAL logs an event before its operation runs and replays the unfinished ones on recovery.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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