l2

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2024 License: CC0-1.0, CC0-1.0, MIT Imports: 12 Imported by: 0

Documentation

Overview

Package l2 is a testing data store that implements a level 2 cache for events with a badger eventstore.

This is a testing environment for building cache strategies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	Ctx context.T
	// L1 is a primary, presumably local store, which should be faster, but may be
	// space constrained.
	L1 *badger.Backend
	// L2 is a secondary, possibly slower but bigger cache. It could be an IC
	// canister, an IPFS based store with an indexing spider or indeed a giant
	// spinning disk.
	L2 eventstore.Store
}

func (*Backend) Close

func (b *Backend) Close()

func (*Backend) CountEvents

func (b *Backend) CountEvents(c context.T, f *filter.T) (count int, err error)

func (*Backend) DeleteEvent

func (b *Backend) DeleteEvent(c context.T, ev *event.T) (err error)

DeleteEvent deletes the event if found. If not found, will return eventstore.ErrEventNotExists.

Relay may have filters to block this, by default only an event author can delete an event, but this is not processed here, it must be done in a previous step.

func (*Backend) Init

func (b *Backend) Init() (err error)

func (*Backend) QueryEvents

func (b *Backend) QueryEvents(c context.T, f *filter.T) (ch event.C,
	err error)

func (*Backend) Revive

func (b *Backend) Revive(ev1 *event.T, c context.T, ch, saveChan event.C)

func (*Backend) SaveEvent

func (b *Backend) SaveEvent(c context.T, ev *event.T) (err error)

SaveEvent stores the event to the local badger store and the L2, and returns any errors from each store. The only error defined here is eventstore.ErrDupEvent if the store already has the event.

Any errors from this method are not fatal, mostly, mostly anything else, like auth- or filter- related denials are from a separate subsystem.

func (*Backend) SaveLoop

func (b *Backend) SaveLoop(c context.T, saveChan event.C)

Jump to

Keyboard shortcuts

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