wal

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 12 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 is the simplest wal implementation.

func NewHydro

func NewHydro(path string, timeout time.Duration) (*Hydro, error)

func (*Hydro) Close

func (h *Hydro) Close() 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)

type HydroEvent

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

HydroEvent indicates a log event.

func NewHydroEvent

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

func (HydroEvent) Encode

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

func (HydroEvent) Key

func (e HydroEvent) Key() []byte

type WAL

type WAL interface {
	Register(EventHandler)
	Recover(context.Context)
	Log(string, any) (Commit, error)
	Close() 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