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
- Variables
- type MirrorKey
- type PGStore
- func (s *PGStore) List(ctx context.Context) (Set, error)
- func (s *PGStore) PinAgent(ctx context.Context, agentID int64) error
- func (s *PGStore) PinMirror(ctx context.Context, k MirrorKey) error
- func (s *PGStore) UnpinAgent(ctx context.Context, agentID int64) error
- func (s *PGStore) UnpinMirror(ctx context.Context, k MirrorKey) error
- type Set
- type Store
Constants ¶
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 ¶
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).
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 ¶
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.
type PGStore ¶
type PGStore struct {
// contains filtered or unexported fields
}
PGStore is Store on Postgres.
func (*PGStore) PinAgent ¶
PinAgent pins agent id for the caller. Idempotent. An agent the caller cannot see is ErrNoSuchAgent.
func (*PGStore) PinMirror ¶
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 ¶
UnpinAgent removes the caller's pin of agent id. Idempotent.
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.