replicationhttp

package
v0.1.0-alpha.14 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package replicationhttp transfers verified database snapshots over HTTPS.

It is intentionally only the bootstrap half of replication. After an import, callers attach the returned tokens to the WebSocket change-feed receiver. The authenticated durable-consumer name is server controlled; clients never select it in an HTTP header or URL.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidBootstrapResponse reports missing or inconsistent snapshot response metadata.
	ErrInvalidBootstrapResponse = errors.New("meldbase replication bootstrap: invalid response")
	// ErrBootstrapHTTPSRequired reports a URL or response that fails the verified HTTPS requirement.
	ErrBootstrapHTTPSRequired = errors.New("meldbase replication bootstrap: HTTPS is required")
)

Functions

This section is empty.

Types

type Authorize

type Authorize = replicationauth.Authorize

Authorize verifies a replication peer and returns its server-assigned durable consumer name.

Typical deployments map a verified mTLS client certificate fingerprint to that name. It must not derive the name from a user-controlled request value.

func NewMTLSAuthorizer

func NewMTLSAuthorizer(config MTLSConfig) (Authorize, error)

NewMTLSAuthorizer creates a peer authorizer using verified client certificate fingerprints.

The WebSocket adapter uses the same authorizer. The enclosing http.Server must still require and verify client certificates in its tls.Config.

type Bootstrap

type Bootstrap struct {
	Backup          meldbase.BackupResult
	CheckpointToken uint64
	SnapshotToken   uint64
}

Bootstrap records the verified snapshot and the positions needed to resume replication.

Supply its feed tokens to replicationws.ReceiverConfig.

func Fetch

func Fetch(ctx context.Context, config FetchConfig) (Bootstrap, error)

Fetch downloads, verifies, and atomically imports a database snapshot over HTTPS.

Redirects are disabled. It requires an actual TLS response even when callers provide a custom HTTP transport, preventing a transport shim from silently downgrading the security contract.

type FetchConfig

type FetchConfig struct {
	URL         string
	HTTPClient  *http.Client
	Destination string
	MaxBytes    uint64
}

FetchConfig sets the snapshot source, destination file, HTTP client, and download limit.

HTTPClient must use the deployment's mTLS client certificate and trusted server roots.

type MTLSConfig

type MTLSConfig = replicationauth.MTLSConfig

MTLSConfig sets the verified certificate mappings shared by snapshot and WebSocket replication.

type Source

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

Source serves a verified snapshot after establishing its durable consumer checkpoint.

func NewSource

func NewSource(config SourceConfig) (*Source, error)

NewSource validates configuration and returns an HTTP handler source.

func (*Source) ServeHTTP

func (source *Source) ServeHTTP(writer http.ResponseWriter, request *http.Request)

ServeHTTP sends a verified database snapshot to an authenticated replication peer.

It accepts only a GET with no browser Origin. The source lease covers both bootstrap and a subsequent replicationws source session, preventing two transports from racing one durable checkpoint.

type SourceConfig

type SourceConfig struct {
	DB               *meldbase.DB
	Authorize        Authorize
	ArchiveDirectory string
	Buffer           int
}

SourceConfig sets the database, peer authorization, and temporary snapshot storage for an HTTPS handler.

TLS and client-certificate verification belong to the enclosing http.Server; Authorize enforces its application-level identity mapping.

Jump to

Keyboard shortcuts

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