roster

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: GPL-3.0 Imports: 5 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 roster is the party's list of channels: for each peer its local name (design §3.1: names are local), the channel id, the relay the channel lives on, this party's side and token, and how far the invite has gone. It is one record, key "peers", in the party's store, so every fleet host that holds the store can serve every channel. The peer's root key and card live on the channel record (store.Channel), not here.

Index

Constants

View Source
const Key = "peers"

Key is the roster record's key in the store.

Variables

This section is empty.

Functions

func Update

func Update(ctx context.Context, b store.Backend, fn func(*Roster) error) error

Update loads the roster, applies fn and commits, reloading and reapplying when another host committed in between.

Types

type Peer

type Peer struct {
	Name    string `json:"name"`
	Channel string `json:"channel"`
	Relay   string `json:"relay"`
	Side    Side   `json:"side"`
	Token   string `json:"token"`
	State   State  `json:"state"`
}

Peer is one channel as this party sees it.

type Roster

type Roster struct {
	Peers []Peer
	// contains filtered or unexported fields
}

Roster is the record loaded at a version; Set changes it in memory and Commit writes it back under CAS.

func Load

func Load(ctx context.Context, b store.Backend) (*Roster, error)

Load reads the roster, empty at version 0 when absent.

func (*Roster) ByChannel

func (r *Roster) ByChannel(id string) *Peer

ByChannel is the peer on channel id, nil when none.

func (*Roster) ByName

func (r *Roster) ByName(name string) *Peer

ByName is the peer called name, nil when none.

func (*Roster) Commit

func (r *Roster) Commit(ctx context.Context) error

Commit writes the roster as version Version()+1; another host's commit in between is store.ErrConflict and changes nothing.

func (*Roster) Remove added in v0.3.0

func (r *Roster) Remove(name, channel string) bool

Remove drops the peer named name on channel, and reports whether it was there.

func (*Roster) Set

func (r *Roster) Set(p Peer)

Set adds p, replacing the peer of the same name.

func (*Roster) Version

func (r *Roster) Version() int64

Version is the loaded version; Commit raises it.

type Side

type Side string

Side is which token a party holds on a channel.

const (
	// Host created the channel: it invited.
	Host Side = "host"
	// Guest joined with the invite token: it accepted.
	Guest Side = "guest"
)

type State

type State string

State is how far the invite has gone.

const (
	// Invited: the host created the channel and waits for the guest's card and the code.
	Invited State = "invited"
	// Accepted: the guest joined, built the session and sent its card; the host's confirm is pending.
	Accepted State = "accepted"
	// Confirmed: the host checked the session identity and the code and pinned the guest's card.
	Confirmed State = "confirmed"
	// Gone: the peer forgot the channel (its bye arrived). Nothing is sent or
	// pulled on it; the name stays taken until this party forgets it too.
	Gone State = "gone"
)

Jump to

Keyboard shortcuts

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