server

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package server implements the synapse admin RPC service. The AdminServiceHandler an embedder mounts on its own [http.ServeMux] is a thin adapter from the ConnectRPC interface to the user's existing es.EventStore, es.SnapshotStore, and es.CheckpointStore.

Typical wiring:

stores := server.Stores{
    Events:      eventStore,
    Snapshots:   snapshotStore,
    Checkpoints: checkpointStore,
}
adminSrv := server.New(stores)

mux := http.NewServeMux()
path, handler := adminv1connect.NewAdminServiceHandler(adminSrv)
mux.Handle(path, handler)
http.ListenAndServe(":9090", mux)

See ADR-0033.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server implements adminv1connect.AdminServiceHandler. It carries no goroutines and no state beyond the stores it wraps; it is safe for concurrent use to the extent the underlying stores are.

func New

func New(stores Stores) *Server

New returns a Server that serves admin RPCs against stores.

func (*Server) GetCheckpoint

GetCheckpoint returns the saved position for a named projection. found=false when no checkpoint has been saved for that name.

func (*Server) GetSnapshot

GetSnapshot returns the latest snapshot for a stream. found=false when no snapshot exists.

func (*Server) ListCheckpoints

ListCheckpoints yields every (name, position) pair the checkpoint store has saved. Backends that cannot enumerate names yield es.ErrUnsupported from Names; the server maps that to CodeUnimplemented. Each name's position is loaded individually so the stream carries fully-populated Checkpoint messages; this is N+1 against the checkpoint store but the count is typically small.

func (*Server) ListDeadLetterProjections added in v0.5.0

ListDeadLetterProjections enumerates projection names with dead- letter entries (ADR-0041). Returns CodeUnimplemented when no DeadLetterStore is configured.

func (*Server) ListDeadLetters added in v0.5.0

ListDeadLetters yields dead-letter entries for a projection in OccurredAt order. Returns CodeUnimplemented when no DeadLetterStore is configured; CodeInvalidArgument on empty projection.

func (*Server) ListStreams

ListStreams yields every stream id the event store knows about. Backends that cannot enumerate streams yield es.ErrUnsupported from Streams; the server maps that to CodeUnimplemented.

func (*Server) RemoveDeadLetter added in v0.5.0

RemoveDeadLetter deletes a DLQ entry by id. Idempotent.

func (*Server) ResetCheckpoint

ResetCheckpoint clears the saved position for a named projection. A Load runs first so the response can report whether a checkpoint existed; this is one extra round trip against the checkpoint store per Reset, which is acceptable for an admin operation. The Reset itself is idempotent — see es.CheckpointStore.

func (*Server) RestoreEvents added in v0.4.0

RestoreEvents streams envelopes from the client and Appends them to the destination event store, batching consecutive events for the same stream into a single Append. The destination must be empty for the affected streams — version collisions surface as FailedPrecondition and stop the restore mid-stream (ADR-0040).

func (*Server) RestoreSnapshots added in v0.4.0

RestoreSnapshots streams snapshots from the client and Saves each to the destination snapshot store. Snapshots are overwrite-on-conflict, so re-runs are idempotent up to each snapshot's own version (ADR-0040).

func (*Server) ShredSubject

ShredSubject destroys the data-encryption key for the named subject via the wired crypto.KeyStore. Returns CodeUnimplemented when no KeyStore is configured; CodeInvalidArgument on an empty subject. The underlying KeyStore.Shred is idempotent.

func (*Server) StreamEvents

StreamEvents yields events from a single stream in version order. from_version is exclusive; limit caps the number returned (0 means no cap).

func (*Server) StreamsBySubject

StreamsBySubject yields every stream id containing at least one event tagged with the given Subject. Backends that do not maintain a subject index yield es.ErrUnsupported; the server maps that to CodeUnimplemented. An empty subject yields zero results.

type Stores

type Stores struct {
	Events      es.EventStore
	Snapshots   es.SnapshotStore
	Checkpoints es.CheckpointStore

	// Keys, when non-nil, enables the ShredSubject RPC. Wire your
	// keystore implementation here; the admin server delegates Shred
	// directly to it. See ADR-0036.
	Keys crypto.KeyStore

	// DeadLetters, when non-nil, enables the ListDeadLetterProjections,
	// ListDeadLetters, and RemoveDeadLetter RPCs (ADR-0041). The same
	// store is typically wired into a projection.Runner via
	// projection.WithDeadLetter so failed events land here.
	DeadLetters es.DeadLetterStore
}

Stores is the set of synapse stores the admin server reads from. Events, Snapshots, and Checkpoints are required; Keys and DeadLetters are optional. Nil values for the required fields cause the corresponding RPCs to fail with INTERNAL. Nil Keys / DeadLetters make their RPCs return CodeUnimplemented (the rest of the surface is unaffected).

Jump to

Keyboard shortcuts

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