Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrDupEvent = errors.New("duplicate: event already exists")
Functions ¶
func IsNegentropySession ¶ added in v0.13.0
Types ¶
type Notifier ¶ added in v0.17.14
type Notifier interface {
Notify(context.Context, *nostr.Event) error
Notifications(context.Context) (<-chan *nostr.Event, error)
}
Notifier is implemented by stores that can propagate events between several processes sharing the same storage, so that a relay running as multiple instances can push events published to one instance to the subscribers of all the others.
The relay calls Notify for every accepted event, after saving it; ephemeral events are passed too even though they are never saved. Notifications must deliver every event passed to Notify by any process, including the calling one, and keep its channel open until ctx is done, reconnecting to the underlying transport as needed.
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.
Init() error
// Close must be called after you're done using the store, to free up resources and so on.
Close()
// QueryEvents 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(context.Context, nostr.Filter) (chan *nostr.Event, error)
// DeleteEvent just deletes an event, no side-effects.
DeleteEvent(context.Context, *nostr.Event) error
// SaveEvent just saves an event, no side-effects.
SaveEvent(context.Context, *nostr.Event) error
// ReplaceEvent atomically replaces a replaceable or addressable event.
// Conceptually it is like a Query->Delete->Save, but streamlined.
ReplaceEvent(context.Context, *nostr.Event) error
}
Store is a persistence layer for nostr events handled by a relay.
Click to show internal directories.
Click to hide internal directories.