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 (*Service) CloseAll ¶ added in v0.5.3
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).