replicasync

package
v2.36.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PubsubEvent = "replica"

Functions

func CreateDERPMeshTLSConfig added in v2.8.5

func CreateDERPMeshTLSConfig(hostname string, tlsCertificates []tls.Certificate) (*tls.Config, error)

CreateDERPMeshTLSConfig creates a TLS configuration for connecting to peers in the DERP mesh over private networking. It overrides the ServerName to be the expected public hostname of the peer, and trusts all of the TLS server certificates used by this replica (as we expect all replicas to use the same TLS certificates).

func DERPPingPeerReplica added in v2.36.0

func DERPPingPeerReplica(ctx context.Context, client http.Client, relayAddress string) error

DERPPingPeerReplica pings a peer replica over it's internal relay address to ensure it's reachable and alive for health purposes.

Types

type Manager

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

Manager keeps the replica up to date and in sync with other replicas.

func New

func New(ctx context.Context, logger slog.Logger, db database.Store, ps pubsub.Pubsub, options *Options) (*Manager, error)

New registers the replica with the database and periodically updates to ensure it's healthy. It contacts all other alive replicas to ensure they are reachable.

func (*Manager) AllPrimary

func (m *Manager) AllPrimary() []database.Replica

AllPrimary returns every primary replica (not workspace proxy replicas), including itself.

func (*Manager) Close

func (m *Manager) Close() error

func (*Manager) DERPReplicasInRegion added in v2.36.0

func (m *Manager) DERPReplicasInRegion(regionID int32) []database.Replica

DERPReplicasInRegion returns every replica in the given DERP region excluding itself.

func (*Manager) DERPReplicasThisRegion added in v2.36.0

func (m *Manager) DERPReplicasThisRegion() []database.Replica

DERPReplicasThisRegion returns all replicas in the same region excluding itself.

func (*Manager) FetchNATSPeers added in v2.35.0

func (m *Manager) FetchNATSPeers() []string

func (*Manager) ID

func (m *Manager) ID() uuid.UUID

func (*Manager) PublishUpdate

func (m *Manager) PublishUpdate() error

PublishUpdate notifies all other replicas to update.

func (*Manager) Self

func (m *Manager) Self() database.Replica

Self represents the current replica.

func (*Manager) SetCallback

func (m *Manager) SetCallback(name string, callback func())

SetCallback sets a named function to execute whenever new peers are refreshed or updated. Calling SetCallback again with the same name replaces the prior callback. Passing nil removes the named callback.

func (*Manager) SetSelfNATSPort added in v2.35.0

func (m *Manager) SetSelfNATSPort(port int32)

func (*Manager) UpdateNow

func (m *Manager) UpdateNow(ctx context.Context) error

UpdateNow synchronously updates replicas.

type Options

type Options struct {
	ID              uuid.UUID
	CleanupInterval time.Duration
	UpdateInterval  time.Duration
	PeerTimeout     time.Duration
	RelayAddress    string
	RegionID        int32
	TLSConfig       *tls.Config
	ClusterHost     string
}

Jump to

Keyboard shortcuts

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