syncserver

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package syncserver is the sync socket (GET /api/v1/sync): the automerge-repo network protocol, version 1, over a WebSocket, so the stock @automerge/automerge-repo WebSocket adapter connects to the engine unchanged (docs/adr/0007). It is a driving adapter: it turns protocol messages into calls on the engine's shared-draft service and nothing more, and it keeps no state a later connection needs.

One connection is one peer (a browser tab, a terminal). Per document it holds an Automerge sync state for as long as the connection lives; across replicas it learns of changes through the fan-out port, and, because a fan-out hint may be lost, it also asks every peer it serves for heads on a timer. A lost hint costs latency, never an edit (docs/adr/0008).

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 serves the sync socket.

func New

func New(shared *engine.Shared, fan fanout.Bus, authz auth.Authorizer, log *slog.Logger) *Server

New returns a server over the engine's shared drafts. authz decides, per document, whether a peer may read or write it.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP upgrades the request and runs one peer until it leaves.

Jump to

Keyboard shortcuts

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