Documentation ¶
Overview ¶
Package sys manages the state of a running dex system.
Index ¶
- Variables
- func Funcs[K Kernel, D Device[B], B Button](redact bool) func(manager *Manager[K, D, B], log *slog.Logger) rpc.Funcs
- type Button
- type Device
- type Kernel
- type Manager
- func (m *Manager[K, D, B]) Close() error
- func (m *Manager[K, D, B]) Configure(ctx context.Context, cfg *config.System) error
- func (m *Manager[K, D, B]) Datadir() string
- func (m *Manager[K, D, B]) DeviceFor(svc rpc.UID) (D, error)
- func (m *Manager[K, D, B]) Kernel() (kernel K, ok bool)
- func (m *Manager[K, D, B]) SetBuiltins(ctx context.Context, builtins map[string]jsonrpc2.Binder) error
- func (m *Manager[K, D, B]) SetFuncs(funcs rpc.Funcs)
- func (m *Manager[K, D, B]) Store() Store
- type NewDevice
- type NewKernel
- type Page
- type Store
Constants ¶
This section is empty.
Variables ¶
var ErrAllowedMissingDevice = errors.New("allowed missing device")
ErrAllowedMissingDevice is returned by Manager.DeviceFor when a device is not available for a service, but the device has been configured with config.Device.Required set to false.
var ErrNotFound = jsonrpc2.NewError(rpc.ErrCodeNotFound, "item not found")
ErrNotFound is returned by Store.Get if the item is not found.
Functions ¶
func Funcs ¶
func Funcs[K Kernel, D Device[B], B Button](redact bool) func(manager *Manager[K, D, B], log *slog.Logger) rpc.Funcs
Funcs returns an rpc.Funcs with a function table for accessing the manager.
The RPC methods in the table are:
- "system": returns the current config.System
If redact is true, fields marked with private will be redacted using private.Redact.
Types ¶
type Device ¶
type Device[B Button] interface { Serial() string SetPages(ctx context.Context, deflt *string, pages []string) error SendTo(service rpc.UID, listen []config.Button) error Layout() (rows, cols int) Key(row, col int) int CurrentName() string Page(name string) (p Page[B], ok bool) PageNames() []string PageDetails() map[string][]config.Button Bounds() (image.Rectangle, error) RawImage(img image.Image) (*ardilla.RawImage, error) SetDisplayTo(ctx context.Context, name string) error SetBrightness(percent int) error SleepState() string Last() time.Time Wake(ctx context.Context) Blank() error Clear() error Close() error }
Device is the dex device interface.
type Kernel ¶
type Kernel interface { Builtin(ctx context.Context, uid string, dialer net.Dialer, binder jsonrpc2.Binder) error Funcs(funcs rpc.Funcs) jsonrpc2.Handler Conn(ctx context.Context, uid string) (rpc.Connection, time.Time, bool) Spawn(ctx context.Context, stdout, stderr io.Writer, done func(), uid, name string, args ...string) error SetDrop(uid string, drop func() error) error Kill(uid string) Close() error }
Kernel is the RPC kernel interface.
type Manager ¶
Manager is a dex system manager.
func NewManager ¶
func NewManager[K Kernel, D Device[B], B Button](kernel NewKernel[K], device NewDevice[K, D, B], store Store, datadir string, log *slog.Logger, level *slog.LevelVar, addSource *atomic.Bool) (*Manager[K, D, B], error)
NewManager returns a new system manager.
func (*Manager[K, D, B]) Configure ¶
Configure changes a managed system's state to match the provided configuration. If the system is not yet running, it will be started.
func (*Manager[K, D, B]) Kernel ¶
Kernel returned the RPC kernel held by the manager and whether the kernel is running.
func (*Manager[K, D, B]) SetBuiltins ¶
func (m *Manager[K, D, B]) SetBuiltins(ctx context.Context, builtins map[string]jsonrpc2.Binder) error
SetBuiltins inserts the provided builtins into the RPC kernel's handler. If builtins is nil the entire kernel mapping table is reset.
type NewDevice ¶
type NewDevice[K Kernel, D Device[B], B Button] func(ctx context.Context, pid ardilla.PID, serial string, kernel K, log *slog.Logger) (D, error)
NewDevice is a new dex device constructor.
type NewKernel ¶
type NewKernel[K Kernel] func(ctx context.Context, network string, options jsonrpc2.NetListenOptions, log *slog.Logger) (K, error)
NewKernel is a new RPC kernel constructor.
type Store ¶
type Store interface { Set(owner rpc.UID, item string, val []byte) error Get(owner rpc.UID, item string) (val []byte, err error) Put(owner rpc.UID, item string, new []byte) (old []byte, written bool, err error) Delete(owner rpc.UID, item string) error Drop(owner rpc.UID) error DropModule(module string) error }
Store is a common persistent data store held by the manager.