streamsession

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package streamsession retains bounded transaction evidence across transports. The authenticated owner serializes calls and polls Tick during idle input. No method performs authentication, schedules timers or retains image pixels.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLease    = errors.New("screen: stale boot, lease or binding")
	ErrBusy     = errors.New("screen: writer or transaction active")
	ErrStale    = errors.New("screen: transaction consumed or evidence evicted")
	ErrConflict = errors.New("screen: transaction digest conflict")
	ErrCooldown = errors.New("screen: full refresh cooldown")
)

Functions

This section is empty.

Types

type Binding

type Binding struct {
	Lease
	Serial uint64
}

type Epoch

type Epoch struct {
	Boot       [16]byte
	Generation uint64
}

type Lease

type Lease struct {
	Epoch
	Claim [16]byte
}

type Result

type Result struct {
	Status       streamrx.Status
	CurrentImage bool
}

type Session

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

func New

func New(boot [16]byte, config streamrx.Config, sink streamrx.Sink, minimum time.Duration) (*Session, error)

New conservatively starts with a full cooldown: reboot cannot prove when the preceding firmware last refreshed. Boot must come from the board's RNG.

func (*Session) Abort

func (s *Session) Abort(binding Binding) error

Abort is also used for authenticated framing failures and USB preemption. It never releases the binding: only its owner may disconnect it.

func (*Session) Acquire

func (s *Session) Acquire(expected Epoch, claim [16]byte) (Lease, error)

Acquire uses compare-and-swap. The caller generates a fresh random 128-bit claim for each logical acquisition and retains that same claim for retries. An exact lost-ACK retry has no side effects, including when a writer is bound.

func (*Session) Begin

func (s *Session) Begin(binding Binding, tx Transaction, now time.Duration) error

func (*Session) Bind

func (s *Session) Bind(lease Lease) (Binding, error)

Bind resumes a remembered lease, not one guessed from Hello. Each connection gets a non-reusable serial so a late disconnect cannot close its replacement.

func (*Session) Commit

func (s *Session) Commit(binding Binding, tx Transaction, now time.Duration) error

func (*Session) Cooldown

func (s *Session) Cooldown() time.Duration

Cooldown reports the remaining floor without mutating the monotonic clock.

func (*Session) Disconnect

func (s *Session) Disconnect(binding Binding) error

Disconnect must use the binding of the connection that actually closed. Completed evidence survives; partial staging closes without a refresh.

func (*Session) Epoch

func (s *Session) Epoch() Epoch

Epoch exposes discovery only, never another writer's claim.

func (*Session) Fence

func (s *Session) Fence() error

Fence revokes completion/ownership for credential changes without resetting physical cadence. The owner must first disconnect/abort its live binding. The new generation is unclaimed; only a fresh Acquire may establish a writer.

func (*Session) Query

func (s *Session) Query(binding Binding, tx Transaction) (Result, error)

Query distinguishes an unseen future ID from consumed IDs whose evidence has been evicted. A failed/aborted ID can never restart a controller RAM pointer.

func (*Session) Tick

func (s *Session) Tick(now time.Duration) error

Tick runs even when no input arrives. Regressing clocks invalidate staging; observations never go backwards across receiver replacements or leases.

func (*Session) Write

func (s *Session) Write(binding Binding, tx Transaction, pass uint8, offset uint32, pixels []byte, now time.Duration) error

type Transaction

type Transaction struct {
	Lease
	ID     uint64
	Digest [sha256.Size]byte
}

Jump to

Keyboard shortcuts

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