l2

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: GPL-2.0, MIT Imports: 11 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
	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
}

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) 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.

Jump to

Keyboard shortcuts

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