memory

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 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 memory implements the neighbor table database in memory, for tests and embeddings that prefer no state directory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB is the in-memory neighbor table: one mutex over a slice, interface IDs allocated from a monotonic counter.

func New

func New() *DB

New returns an empty table.

func (*DB) All

func (d *DB) All(ctx context.Context) ([]*links.Link, error)

All returns every stored entry, freshly copied: callers own the entries they hold.

func (*DB) ByNeighbor

func (d *DB) ByNeighbor(ctx context.Context, ia addr.IA) (*links.Link, error)

ByNeighbor returns the live entry of the neighbor.

func (*DB) ByRemote

func (d *DB) ByRemote(ctx context.Context, remote netip.AddrPort) (*links.Link, error)

ByRemote returns the live entry whose remote or rendezvous address matches.

func (*DB) Close

func (d *DB) Close() error

Close is a no-op.

func (*DB) Insert

func (d *DB) Insert(ctx context.Context, l *links.Link) error

Insert stores a new entry: an entry carrying no interface ID is allocated one, and one carrying an ID takes it, refused when the ID is held or when links.Check refuses the entry.

func (*DB) Update

func (d *DB) Update(ctx context.Context, l *links.Link) error

Update replaces the stored entry with the same interface ID, refused when links.Check refuses the replacement.

Jump to

Keyboard shortcuts

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