l2

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2024 License: CC0-1.0 Imports: 13 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 B

type B = []byte

type Backend

type Backend struct {
	Ctx context.T
	WG  *sync.WaitGroup
	// 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
	// PollFrequency is how often the L2 is queried for recent events
	PollFrequency time.Duration
	// PollOverlap is the multiple of the PollFrequency within which polling the L2
	// is done to ensure any slow synchrony on the L2 is covered (2-4 usually)
	PollOverlap timestamp.T
	// EventSignal triggers when the L1 saves a new event from the L2
	//
	// caller is responsible for populating this
	EventSignal event.C
}

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)

type E

type E = error

type N added in v0.0.14

type N = int

type S

type S = string

Jump to

Keyboard shortcuts

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