eventstore

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: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDupEvent       = errors.New("duplicate: event already exists")
	ErrEventNotExists = errors.New("unknown: event not known by any source of this relay")
)

Functions

func GetAddrTagElements

func GetAddrTagElements(tagValue S) (k uint16, pkb B, d S)

func TagSorter

func TagSorter(a, b tag.T) int

Types

type B

type B = []byte

type Cache

type Cache interface {
	Store
	GCCount() (deleteItems del.Items, err E)
	Delete(serials del.Items) (err E)
}

Cache is a sketch of an expanded enveloper that might be used for a size-constrained event store.

type Ctx

type Ctx = context.T

type E

type E = error

type EV

type EV = *event.T

type N added in v0.0.14

type N = int

type OK

type OK = okenvelope.T

type RelayInterface

type RelayInterface interface {
	Publish(c Ctx, evt EV) E
	QuerySync(c Ctx, f *filter.T,
		opts ...subscriptionoption.I) ([]EV, E)
}

RelayInterface is a wrapper thing that unifies Store and nostr.Relay under a common API.

type RelayWrapper

type RelayWrapper struct {
	Store
}

func (RelayWrapper) Publish

func (w RelayWrapper) Publish(c Ctx, evt EV) (err E)

func (RelayWrapper) QuerySync

func (w RelayWrapper) QuerySync(c Ctx, f *filter.T,
	opts ...subscriptionoption.I) ([]EV, E)

type Req

type Req = *http.Request

type Responder

type Responder = http.ResponseWriter

type S

type S = string

type Store

type Store interface {
	// Init is called at the very beginning by [Server.Start], after
	// [Relay.Init], allowing a storage to initialize its internal resources.
	// The parameters can be used by the database implementations to set custom
	// parameters such as cache management and other relevant parameters to the
	// specific implementation.
	Init() (err E)
	// Close must be called after you're done using the store, to free up
	// resources and so on.
	Close()
	// QueryEvents is invoked upon a client's REQ as described in NIP-01. it
	// should return a channel with the events as they're recovered from a
	// database. the channel should be closed after the events are all
	// delivered.
	QueryEvents(c Ctx, f *filter.T) (ch event.C, err E)
	// CountEvents performs the same work as QueryEvents but instead of
	// delivering the events that were found it just returns the count of events
	CountEvents(c Ctx, f *filter.T) (count int, err E)
	// DeleteEvent is used to handle deletion events, as per NIP-09.
	DeleteEvent(c Ctx, ev EV) (err E)
	// SaveEvent is called once Relay.AcceptEvent reports true.
	SaveEvent(c Ctx, ev EV) (err E)
}

Store is a persistence layer for nostr events handled by a relay.

type SubID

type SubID = subscriptionid.T

type WS

type WS = *relayws.WS

Directories

Path Synopsis
IC
del
keys
Package keys is a composable framework for constructing badger keys from fields of events.
Package keys is a composable framework for constructing badger keys from fields of events.
Package l2 is a testing data store that implements a level 2 cache for events with a badger eventstore.
Package l2 is a testing data store that implements a level 2 cache for events with a badger eventstore.

Jump to

Keyboard shortcuts

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