session

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 29 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 session is what the daemon serves to agents: persistent device connections, named devices (alice, bob), compact screen listings with stable refs, command runs that answer with what changed, event-driven waits and watches, and recording passed commands into a flow.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dev

type Dev struct {
	Info device.Info
	Name string // alias, e.g. "alice"; guarded by Service.mu
	Drv  driver.Driver

	AppID string
	// contains filtered or unexported fields
}

Dev is one connected device.

Locking (issues #63, #153):

  • Service.mu guards the service's maps and every Dev's Name. It is held briefly, and never while waiting for a Dev's mu.
  • Dev.mu is the device lock: one command at a time per device. Closing a session (tb close, a dropped connection, the daemon stopping) takes it too, so the driver is never closed and the device never freed under a running command: closing waits for the command. A command that gets the lock after its session closed fails (lockOpen).
  • stepsMu guards the recorded steps (below).

The order is Dev.mu, then Service.mu: a command may read a name while it holds its device.

type Service

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

Service holds the devices.

func New

func New() *Service

func (*Service) CloseAll added in v0.5.3

func (s *Service) CloseAll(ctx context.Context)

CloseAll closes every open session's driver: the daemon is stopping (issue #58). A web session's Chrome shuts down and its temporary profile is removed; a phone's or simulator's agent connection closes and the agent is kept for the next run, as at the end of a `tb test` run (`tb close` is what stops it). Each device's lock is freed. The drivers close side by side; those still closing when ctx ends are killed where they can be (web: Chrome's process) and left otherwise. Each close takes the device lock, as tb close does: the daemon has cancelled the commands and waited for them, so it is free unless one is stuck. Sessions whose connection dropped are among them: one still closing (it waits for the command that ran when it dropped) is waited for, or killed, like the others (issue #124).

func (*Service) Register

func (s *Service) Register(srv *daemon.Server)

Register installs the daemon handlers.

Jump to

Keyboard shortcuts

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