Skip to content

pantuza/xwal

Repository files navigation

📜 xWAL

A Cross, thread-safe and buffered Write Ahead Log (WAL) library for Golang applications.

xWAL Logo

XWAL CI Go Reference Go Report Card License Library Latest Version

  • Cross? Yes, we mean you can choose your WAL Backend: Local Filesystem, AWS s3, etc.
  • Thread-safe? Yes, once you have a xwal instance, you can safelly call its methods concurrently.
  • Buffered? Yes, xwal uses an In Memory Buffer that flushes to the chosen WAL Backend asynchronosly.

Installation

go get github.com/pantuza/xwal

Usage

cfg := xwal.NewXWALConfig("") // Uses default configuration

xwal, err := xwal.NewXWAL(cfg) // Creates a new WAL instance
if err != nil {
  panic(err)
}
defer xwal.Close()

// Your WAL is ready to be used. Thus, elsewhere in your code you can call:
err := xwal.Write([]byte(`{"data": "any data in any format serialized to bytes you want to persist in the WAL"}`))
if err != nil {
  panic(err)
}

// Let's suppose your remote backend is failing and you need to Replay data from WAL to it.
// You simply provide xwal a callback function that speaks to your backend and xwal will
// make sure to give you the stored data in the order you want:
func myCallback(entries []*xwalpb.WALEntry) error {
  for _, entry := range entries {
    // Here you can send your data to your backend or do any computation you want
  }
  return nil
}

err = xwal.Replay(myCallback, 5, false) // Replay reads entries from the WAL and sends to your callback function
if err != nil {
  panic(err)
}

Available Backends

Backend Description Examples
Local FS WAL entries are stored on the local filesystem localfs
AWS s3 WAL entries are stored remotely on AWS s3 service s3

Features

TODO: Describe all features Here

Contributing

TODO: Describe how to contribute

License

Knowledge Base

About

A Cross Write Ahead Log library for Golang applications

Resources

License

Stars

Watchers

Forks

Packages

No packages published