replicasync

package
v2.10.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: AGPL-3.0 Imports: 20 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 PingPeerReplica added in v2.8.5

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

PingPeerReplica 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) ID

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

func (*Manager) InRegion

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

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

func (*Manager) PublishUpdate

func (m *Manager) PublishUpdate() error

PublishUpdate notifies all other replicas to update.

func (*Manager) Regional

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

Regional returns all replicas in the same region excluding itself.

func (*Manager) Self

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

Self represents the current replica.

func (*Manager) SetCallback

func (m *Manager) SetCallback(callback func())

SetCallback sets a function to execute whenever new peers are refreshed or updated.

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
}

Jump to

Keyboard shortcuts

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