Documentation
¶
Overview ¶
Package device keeps Core's view of the machine it runs on current while clients are connected, and tells them when it changes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChangedParams ¶
func ChangedParams(snap *Snapshot) models.DeviceChangedNotification
ChangedParams builds the device.changed payload: the state a status display draws from, with nothing in it that identifies the device on its network.
func DefaultReaders ¶
func DefaultReaders() hoststatus.Readers
DefaultReaders returns the generic readers for this operating system.
func StatusResponse ¶
func StatusResponse(snap *Snapshot, actions map[string]string) models.DeviceStatusResponse
StatusResponse builds the device.status result. actions is keyed by method name and already reflects what the caller is allowed to do.
Types ¶
type InternetProber ¶
type InternetProber interface {
Probe(ctx context.Context) hoststatus.InternetState
}
InternetProber decides whether the internet is reachable.
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor reads device state on a schedule while at least one client is connected and publishes device.changed when it differs from what clients were last told. With nobody connected it does nothing at all.
func NewMonitor ¶
NewMonitor builds a monitor. It reads nothing until Run is called and a client connects, or a status is asked for.
func (*Monitor) ClientConnected ¶
func (m *Monitor) ClientConnected()
ClientConnected records that a client is now listening for notifications.
func (*Monitor) ClientDisconnected ¶
func (m *Monitor) ClientDisconnected()
ClientDisconnected records that a client has gone.
func (*Monitor) PowerControl ¶
func (m *Monitor) PowerControl() hoststatus.PowerController
PowerControl returns the controller for power actions on this device.
type Options ¶
type Options struct {
Platform platforms.Platform
Config *config.Instance
Clock clockwork.Clock
// Publish delivers a notification to every connected client.
Publish func(models.Notification)
Prober InternetProber
// Readers are the per-section readers, already resolved against the
// platform.
Readers hoststatus.Readers
// ReadTimeout bounds one section's read. Zero means the default.
ReadTimeout time.Duration
}
Options configures a Monitor.
type Snapshot ¶
type Snapshot struct {
Power *power.Detail
Network *hoststatus.Network
Bluetooth *hoststatus.Bluetooth
Display *hoststatus.Display
System *hoststatus.System
Sections map[string]hoststatus.Availability
Timezone string
PlatformID string
Storage []hoststatus.Volume
Controllers []hoststatus.Controller
UTCOffset int
// StorageKnown and ControllersKnown tell an empty list from no reading.
StorageKnown bool
ControllersKnown bool
ClockReliable bool
}
Snapshot is everything Core knows about the device. A nil section has no reading.