node

package
v1.2.0 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: 16 Imported by: 1 module, 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

Index

Constants

View Source
const (
	Manager = "node"
	// UpdateInterval is the safety net: nodes push every change of their
	// device list, so the master only asks them this often.
	UpdateInterval = 5 * time.Minute
)
View Source
const ConnectionTimeout = 10 * time.Second

Variables

View Source
var (
	ErrManagerNotFound = fmt.Errorf("manager not found")
	ErrDeviceNotFound  = fmt.Errorf("device not found")
)

Functions

func NewMemoryDeviceStore

func NewMemoryDeviceStore(cfg map[string]config.Manager) *deviceStore

Types

type Handler

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

Handler manages the devices of all nodes on the master.

func NewHandler

func NewHandler(log *logrus.Logger, ds storage.Device, nm manager.Nodes, db *gorm.DB) *Handler

NewHandler returns the handler of the node devices. The video streams of its devices pair through the rendezvous of nm when nm provides one (videostream.Provider), through a private one otherwise.

func (*Handler) GetDevice

func (h *Handler) GetDevice(deviceID string) (manager.NodeIdentifier, device.Device, error)

GetDevice returns the device with the id and the node it lives on.

func (*Handler) GetDevices

func (h *Handler) GetDevices() ([]device.Device, error)

func (*Handler) Handle

func (h *Handler) Handle(payload events.NodeConnectedPayload)

func (*Handler) HasDevice

func (h *Handler) HasDevice(device2 device.Device) bool

func (*Handler) Init

func (h *Handler) Init(masterUrl, nodeIdentifier string, authToken *string) error

Init registers the node events, restores the stored node devices and asks the nodes for their current ones. The arguments are the node settings of the other handlers; the master side needs none of them.

func (*Handler) Name

func (h *Handler) Name() string

func (*Handler) RefreshDevices

func (h *Handler) RefreshDevices(force bool) error

RefreshDevices fetches the device lists of all nodes over RPC. Nodes push their changes (UpdateNodeDevices), so this runs when the master starts, when a node connects or drops, and every UpdateInterval as a safety net.

func (*Handler) RegisterDevice

func (h *Handler) RegisterDevice(data device.RegisterData) (device.Device, error)

func (*Handler) Run

func (h *Handler) Run(ctx context.Context, runSocketListener bool) error

func (*Handler) Start

func (h *Handler) Start() error

func (*Handler) StartDevice

func (h *Handler) StartDevice(deviceID string) error

func (*Handler) Stop

func (h *Handler) Stop() error

func (*Handler) StopDevice

func (h *Handler) StopDevice(deviceID string) error

func (*Handler) UpdateNodeDevices added in v1.1.0

func (h *Handler) UpdateNodeDevices(nodeIdentifier manager.NodeIdentifier, managers map[string][]device.Device, sentAt int64) error

UpdateNodeDevices applies a device list a node pushed. Pushes older than the last applied one (sentAt, node clock) are dropped, and so are pushes of a node that isn't connected: it is refreshed completely when it connects.

type NodeDevice

type NodeDevice struct {
	generic.Device
	generic.Info
	// contains filtered or unexported fields
}

NodeDevice is a device that lives on a node. It reports the identity the node announced and forwards everything else to the node through the node manager.

func (*NodeDevice) ClearAppData added in v1.1.0

func (d *NodeDevice) ClearAppData(params *app.Parameter) error

func (*NodeDevice) ConnectionTimeout

func (d *NodeDevice) ConnectionTimeout() time.Duration

func (*NodeDevice) Execute

func (d *NodeDevice) Execute(data string)

Execute is skipped when the node manager has no features.

func (*NodeDevice) GetNodeID

func (d *NodeDevice) GetNodeID() manager.NodeIdentifier

func (*NodeDevice) GetScreenshot

func (d *NodeDevice) GetScreenshot() ([]byte, int, int, error)

func (*NodeDevice) HasFeature

func (d *NodeDevice) HasFeature(feature string) bool

HasFeature is false when the node manager has no features.

func (*NodeDevice) InputText added in v1.1.0

func (d *NodeDevice) InputText(text string) error

InputText implements device.InputCapable by forwarding to the node.

func (*NodeDevice) InstallApp

func (d *NodeDevice) InstallApp(params *app.Parameter) error

func (*NodeDevice) IsAppConnected

func (d *NodeDevice) IsAppConnected() bool

func (*NodeDevice) IsAppInstalled

func (d *NodeDevice) IsAppInstalled(params *app.Parameter) (bool, error)

func (*NodeDevice) NodeManager

func (d *NodeDevice) NodeManager() manager.Nodes

func (*NodeDevice) PressKey added in v1.1.0

func (d *NodeDevice) PressKey(key string) error

PressKey implements device.InputCapable by forwarding to the node.

func (*NodeDevice) ReadLogs added in v1.1.0

func (d *NodeDevice) ReadLogs(lines int) ([]string, error)

ReadLogs implements device.LogReader by forwarding to the node.

func (*NodeDevice) ReadLogsSince added in v1.2.0

func (d *NodeDevice) ReadLogsSince(since string, lines int) ([]string, error)

ReadLogsSince implements device.LogFollower by forwarding to the node.

func (*NodeDevice) RunNativeScript

func (d *NodeDevice) RunNativeScript(script []byte)

RunNativeScript is skipped when the node manager has no native scripts.

func (*NodeDevice) Send

func (d *NodeDevice) Send(script []byte) error

Send forwards the action to the node. The node reports no delivery result.

func (*NodeDevice) SetDeviceState

func (d *NodeDevice) SetDeviceState(state string)

func (*NodeDevice) StartApp

func (d *NodeDevice) StartApp(_ *device.DeviceConfig, appParams *app.Parameter, sessionId string, nodeUrl string) error

StartApp starts the app on the node with the connection settings stored for the device; the config argument of the caller does not apply to node devices.

func (*NodeDevice) StartRecording

func (d *NodeDevice) StartRecording(path string) error

func (*NodeDevice) StartVideo added in v1.1.0

func (d *NodeDevice) StartVideo(ctx context.Context, opts device.VideoOptions) (device.VideoStream, error)

StartVideo implements device.VideoStreamer. The node starts the stream and dials back to the master, which pairs the socket through the rendezvous.

func (*NodeDevice) StopApp

func (d *NodeDevice) StopApp(params *app.Parameter) error

func (*NodeDevice) StopRecording

func (d *NodeDevice) StopRecording() error

func (*NodeDevice) Swipe added in v1.1.0

func (d *NodeDevice) Swipe(fromX, fromY, toX, toY int, duration time.Duration) error

Swipe implements device.InputCapable by forwarding to the node.

func (*NodeDevice) Tap added in v1.1.0

func (d *NodeDevice) Tap(x, y int) error

Tap implements device.InputCapable by forwarding to the node.

func (*NodeDevice) UninstallApp

func (d *NodeDevice) UninstallApp(params *app.Parameter) error

func (*NodeDevice) UpdateDeviceInfos

func (d *NodeDevice) UpdateDeviceInfos(parameter map[string]string)

UpdateDeviceInfos replaces the device parameters with a copy of parameter.

Jump to

Keyboard shortcuts

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