pins

package
v0.213.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT 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 pins is the session switcher's pinned entries (migration 0017): per user, server-stored, so a pin follows its owner across devices. A pin names either a dispatched agent or a mirrored tmux window.

🔴 EVERY METHOD RUNS UNDER THE CALLER'S PRINCIPAL. pins is under FORCE row-level security, so a request sees, adds and removes only its own user's rows; there is no system method. The owner of a new row is the principal's user (owner_id's default), never a parameter.

Index

Constants

View Source
const MaxPerOwner = 200

MaxPerOwner bounds one user's pins. Mirror pins whose windows are gone stay (dormant), so the bound is what keeps them from growing without limit.

Variables

View Source
var ErrNoSuchAgent = errors.New("pins: no such agent")

ErrNoSuchAgent refuses a pin of an agent the caller cannot see (absent, or another user's — the two answer identically).

View Source
var ErrTooMany = fmt.Errorf("pins: a user may pin at most %d entries; unpin one first", MaxPerOwner)

ErrTooMany refuses a pin past MaxPerOwner.

Functions

This section is empty.

Types

type MirrorKey

type MirrorKey struct {
	Host    string
	Session string
	Window  string
}

MirrorKey is a mirrored entry's address — the one its card links by (ui.MirrorRef): host, tmux session, and tmux window id ("@12"), "" for a per-session host's entry. Never the window's index, which tmux renumbers.

func (MirrorKey) Valid

func (k MirrorKey) Valid() error

Valid reports whether k is an address the mirror wire can carry.

type PGStore

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

PGStore is Store on Postgres.

func NewPG

func NewPG(pool *pgxpool.Pool) *PGStore

NewPG returns a Store on pool.

func (*PGStore) List

func (s *PGStore) List(ctx context.Context) (Set, error)

List is the caller's pins.

func (*PGStore) PinAgent

func (s *PGStore) PinAgent(ctx context.Context, agentID int64) error

PinAgent pins agent id for the caller. Idempotent. An agent the caller cannot see is ErrNoSuchAgent.

func (*PGStore) PinMirror

func (s *PGStore) PinMirror(ctx context.Context, k MirrorKey) error

PinMirror pins the mirrored entry at k for the caller. Idempotent. The entry need not be listed now: a pin is an address, kept while its window is gone.

func (*PGStore) UnpinAgent

func (s *PGStore) UnpinAgent(ctx context.Context, agentID int64) error

UnpinAgent removes the caller's pin of agent id. Idempotent.

func (*PGStore) UnpinMirror

func (s *PGStore) UnpinMirror(ctx context.Context, k MirrorKey) error

UnpinMirror removes the caller's pin of the entry at k. Idempotent.

type Set

type Set struct {
	Agents  map[int64]bool
	Mirrors map[MirrorKey]bool
}

Set is one user's pins.

func (Set) Agent

func (s Set) Agent(id int64) bool

Agent reports whether agent id is pinned.

func (Set) Mirror

func (s Set) Mirror(k MirrorKey) bool

Mirror reports whether the mirrored entry at k is pinned.

type Store

type Store interface {
	List(ctx context.Context) (Set, error)
	PinAgent(ctx context.Context, agentID int64) error
	UnpinAgent(ctx context.Context, agentID int64) error
	PinMirror(ctx context.Context, k MirrorKey) error
	UnpinMirror(ctx context.Context, k MirrorKey) error
}

Store is the pin persistence.

Jump to

Keyboard shortcuts

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