Documentation
¶
Overview ¶
Package replicationws transfers database changes between trusted servers over WebSocket.
It has no browser or session authentication: callers must supply an authorization callback backed by mTLS, a private network identity, or another server-to-server credential.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Receive ¶
func Receive(ctx context.Context, config ReceiverConfig) error
Receive applies ordered source changes to a follower and acknowledges locally durable batches.
It returns only after context cancellation, a terminal resync, authentication/transport failure, or a failed follower apply. A batch is ACKed only after it is either covered by the verified bootstrap snapshot or durably applied locally.
Types ¶
type Authorize ¶
type Authorize = replicationauth.Authorize
Authorize verifies a replication peer and returns its server-assigned durable consumer name.
The name scopes retention and must not be derived from an untrusted frame field. Returning an error rejects the WebSocket upgrade.
func NewMTLSAuthorizer ¶
func NewMTLSAuthorizer(config MTLSConfig) (Authorize, error)
NewMTLSAuthorizer creates a peer authorizer using verified client certificate fingerprints.
The enclosing net/http server must require and verify client certificates. This helper does not configure TLS itself: callers must set tls.Config.ClientAuth and trusted roots on the server before requests reach the handler.
type Config ¶
Config supplies the source database, peer authorizer, and replication resource limits.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler sends database changes to authenticated replication peers.
Each connection is pull/acknowledge serialized: it reads hello, writes one batch, waits for its matching ACK, then repeats. This bounds server memory and guarantees that a peer cannot acknowledge an unseen token.
type MTLSConfig ¶
type MTLSConfig = replicationauth.MTLSConfig
MTLSConfig maps verified client certificate fingerprints to durable consumer names.
Fingerprints are lowercase SHA-256 hashes of certificate.Raw. They avoid ambiguous subject/SAN matching and let operators rotate identities with an explicit configuration change.
type ReceiverConfig ¶
type ReceiverConfig struct {
Follower *meldbase.Follower
URL string
DialOptions *websocket.DialOptions
MaxFrameBytes int
SourceCheckpointToken uint64
BootstrapToken uint64
}
ReceiverConfig sets the follower, source connection, and starting replication positions.
DialOptions is where callers install an mTLS HTTP client, private-network proxy or other server-to-server transport identity. It must not be used for browser tokens.