directory

package
v0.47.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 3 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 directory defines peer presence: which peer is attached to which hub, since when. The in-memory implementation covers a single hub; the sqldir subpackages share presence across a fleet.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Directory

type Directory interface {
	// Attach records (or upserts) a peer as attached to rec.Hub.
	Attach(ctx context.Context, rec PeerRecord) error
	// Detach removes peer's record, but only if hub still owns it —
	// a stale detach from a superseded owner must not evict the new
	// one.
	Detach(ctx context.Context, peer, hub string) error
	// Lookup returns peer's record and whether it was found.
	Lookup(ctx context.Context, peer string) (PeerRecord, bool, error)
	// List returns every attached peer, ordered by peer id.
	List(ctx context.Context) ([]PeerRecord, error)
	// ClearHub removes every record owned by hub — called on boot with
	// the hub's own stable id to clear rows left behind by a crash.
	ClearHub(ctx context.Context, hub string) error
}

Directory is the pluggable presence backend behind a Registry. It answers "is peer X attached, and to which hub?" and never holds live connections. The Registry calls it best-effort: a Directory error is logged but never fails a live attach or detach.

type MemoryDirectory

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

MemoryDirectory is the default Directory: a mutex-guarded map, correct for a single hub. Safe for concurrent use.

func NewMemoryDirectory

func NewMemoryDirectory() *MemoryDirectory

NewMemoryDirectory returns an empty in-memory directory.

func (*MemoryDirectory) Attach

func (d *MemoryDirectory) Attach(_ context.Context, rec PeerRecord) error

func (*MemoryDirectory) ClearHub

func (d *MemoryDirectory) ClearHub(_ context.Context, hub string) error

func (*MemoryDirectory) Detach

func (d *MemoryDirectory) Detach(_ context.Context, peer, hub string) error

func (*MemoryDirectory) List

func (*MemoryDirectory) Lookup

func (d *MemoryDirectory) Lookup(_ context.Context, peer string) (PeerRecord, bool, error)

type PeerRecord

type PeerRecord struct {
	Peer        string
	Hub         string // hub instance that owns the live tunnel
	PeerVersion string
	AttachedAt  time.Time
}

PeerRecord is one peer's presence entry: the shareable projection of a live tunnel, everything except the connection itself, which only the owning hub process holds.

Directories

Path Synopsis
Package postgres is the PostgreSQL flavour of the SQL-backed presence directory.
Package postgres is the PostgreSQL flavour of the SQL-backed presence directory.
Package sqldir is a SQL-backed directory.Directory for SQLite and PostgreSQL, sharing peer presence across a fleet of hubs.
Package sqldir is a SQL-backed directory.Directory for SQLite and PostgreSQL, sharing peer presence across a fleet of hubs.
Package sqlite is the SQLite flavour of the SQL-backed presence directory.
Package sqlite is the SQLite flavour of the SQL-backed presence directory.

Jump to

Keyboard shortcuts

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