Repository navigation
Propagate events between instances sharing a database - #31
Merged
Merged
Conversation
relayer v2.3.1 delivers events across instances through eventstore.Notifier, which eventstore v0.17.14 implements for PostgreSQL with LISTEN/NOTIFY. Wrapping the backend in relayStore hid that interface, so expose it again when the backend has one; keep it hidden otherwise, since relayer routes every delivery through it when present. With -driver postgresql, several nostr-relay processes on one database now push each other's events to their subscribers.
# Conflicts: # go.mod # go.sum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bumps relayer to v2.3.1 and eventstore to v0.17.14.
relayer now delivers events across instances through
eventstore.Notifier(fiatjaf/relayer#167, fiatjaf/relayer#168), and eventstore implements it for PostgreSQL withLISTEN/NOTIFY(fiatjaf/eventstore#77).relayStorewraps the backend in an interface value, which hidesNotifierthe same way it hidCounter, so this re-exposes it when the backend has one — and only then, since relayer routes every delivery through aNotifierwhen present, and exposing one that can't listen would makeNewServerfail for sqlite3 and friends.Verified with two
nostr-relay -driver postgresqlprocesses on one Postgres:nak req --streamon both,nak eventto each; a small event and a 9000-byte one (over thepg_notifylimit, announced by id) arrive on both.Note: starting several processes at once against an empty database can race on the schema creation in eventstore's
Init(CREATE OR REPLACE FUNCTIONfrom two connections →duplicate key value violates unique constraint "pg_proc_proname_args_nsp_index"). That's pre-existing and only bites on first boot; start one instance first, or run migrations ahead of scaling out.