Versions in this module Expand all Collapse all v1 v1.0.0 Oct 28, 2026 Changes in this version + const DefaultDebounce + const DefaultReadLimit + const ReasonSinkError + const ReasonUnavailable + var DefaultPalette = []string + var ErrClosed = errors.New("yjsrelay: hub closed") + var ErrRejected = errors.New("yjsrelay: snapshot rejected") + var ErrUnavailable = errors.New("yjsrelay: snapshot sink unavailable") + func ValidateLexicalJSON(content []byte) error + type Codes struct + Rejected int + Unavailable int + type FlushError struct + Detail string + Err error + Reason string + Room string + func (e *FlushError) Error() string + func (e *FlushError) Transient() bool + func (e *FlushError) Unwrap() []error + type FlushResult struct + ContentFlushed bool + RoomFound bool + type Handler struct + func NewHandler(hub *Hub, verifier TokenVerifier, opts ...HandlerOption) *Handler + func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) + type HandlerOption func(*handlerConfig) + func WithAllowedOrigins(origins ...string) HandlerOption + func WithRoomFunc(f func(*http.Request) string) HandlerOption + type Hub struct + func New(sink SnapshotSink, opts ...Option) *Hub + func (h *Hub) Close(ctx context.Context) error + func (h *Hub) Flush(ctx context.Context, id string) (FlushResult, error) + func (h *Hub) Freeze(ctx context.Context, id, version string) bool + func (h *Hub) Lookup(id string) (RoomInfo, bool) + func (h *Hub) RoomCount() int + type Identity struct + Attrs map[string]string + DisplayName string + UserID string + type Join struct + Identity Identity + Room string + RoomAttrs map[string]string + type Option func(*config) + func WithCodes(codes Codes) Option + func WithDebounce(d time.Duration) Option + func WithLogger(l log.Logger) Option + func WithPalette(colors []string) Option + func WithReadLimit(n int64) Option + func WithSessionObserver(o SessionObserver) Option + type RejectError struct + Detail string + Reason string + func (e *RejectError) Error() string + func (e *RejectError) Is(target error) bool + type RoomInfo struct + Attrs map[string]string + Editors int + Frozen bool + ID string + type Session struct + Identity Identity + Room string + RoomAttrs map[string]string + type SessionObserver interface + SessionJoined func(ctx context.Context, s Session) + SessionLeft func(ctx context.Context, s Session) + type Snapshot struct + Author Identity + Content []byte + Room string + RoomAttrs map[string]string + State []byte + type SnapshotSink interface + Load func(ctx context.Context, room string) ([]byte, error) + Save func(ctx context.Context, snap Snapshot) error + type TokenVerifier interface + Verify func(ctx context.Context, token string) (Join, error) + type TokenVerifierFunc func(ctx context.Context, token string) (Join, error) + func (f TokenVerifierFunc) Verify(ctx context.Context, token string) (Join, error)