app

package
v0.0.0-...-7dad292 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResizeMessage byte = iota + 1
	DelayMessage
)
View Source
const (
	//Assuming there will be a moderate number of control messages, so let's set ot 1kB
	ControlRecorderBufferSize = 1024
)
View Source
const (
	DefaultPlaybackSleepIntervalMs = uint(100)
)
View Source
const (
	//It is used as a length of a memory region in bytes that is used to buffer
	//the session recording. 4455 comes from the estimated typical terminal size in
	//bytes (height=135 width=33) multiplied by 4 bytes of of terminal codes to get
	//an estimate of a typical screen frame size in bytes. So we round to 4kB
	RecorderBufferSize = 4 * 4096
)

Variables

View Source
var (
	ErrDeviceNotFound     = errors.New("device not found")
	ErrDeviceNotConnected = errors.New("device not connected")
)

App errors

View Source
var (
	ErrUnknownMessage = errors.New("message of unknown type")
)
View Source
var (
	//Any session that transfers at least one byte above this limit will be automatically
	//closed. This is set to 8MB, based on a research that a typical couple of minutes session
	//of `top -d1` (top refreshing every second) is 2MB large (at terminal height=135 width=33))
	//Note: this refers to the number of bytes seen on the terminal stdout, as opposed
	//      to the number of bytes saved in the db. The key difference being:
	//      the latter is compressed.
	//see: https://northerntech.atlassian.net/browse/MEN-4448
	MessageSizeLimit = 8 * 1024 * 1024
)

Functions

This section is empty.

Types

type App

type App interface {
	HealthCheck(ctx context.Context) error
	ProvisionDevice(ctx context.Context, tenantID string, device *model.Device) error
	GetDevice(ctx context.Context, tenantID, deviceID string) (*model.Device, error)
	DeleteDevice(ctx context.Context, tenantID, deviceID string) error
	UpdateDeviceStatus(ctx context.Context, tenantID, deviceID, status string) error
	PrepareUserSession(ctx context.Context, sess *model.Session) error
	LogUserSession(ctx context.Context, sess *model.Session, sessionType string) error
	FreeUserSession(ctx context.Context, sessionID string, sessionTypes []string) error
	GetSessionRecording(ctx context.Context, id string, w io.Writer) (err error)
	SaveSessionRecording(ctx context.Context, id string, sessionBytes []byte) error
	GetRecorder(ctx context.Context, sessionID string) io.Writer
	GetControlRecorder(ctx context.Context, sessionID string) io.Writer
	DownloadFile(ctx context.Context, userID string, deviceID string, path string) error
	UploadFile(ctx context.Context, userID string, deviceID string, path string) error
	Shutdown(timeout time.Duration)
	ShutdownDone()
	RegisterShutdownCancel(context.CancelFunc) uint32
	UnregisterShutdownCancel(uint32)
}

App interface describes app objects

func New

func New(ds store.DataStore, inv inventory.Client, wf workflows.Client, config ...Config) App

NewApp initialize a new deviceconnect App

type Config

type Config struct {
	HaveAuditLogs bool
}

type Control

type Control struct {
	Type           byte
	Offset         int
	DelayMs        uint16
	TerminalWidth  uint16
	TerminalHeight uint16
}

func (Control) MarshalBinary

func (c Control) MarshalBinary() []byte

func (*Control) UnmarshalBinary

func (c *Control) UnmarshalBinary(controlMessageBuffer []byte) (err error)

type ControlRecorder

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

func NewControlRecorder

func NewControlRecorder(ctx context.Context,
	sessionID string,
	store store.DataStore) *ControlRecorder

func (*ControlRecorder) Write

func (r *ControlRecorder) Write(d []byte) (n int, err error)

type Playback

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

func NewPlayback

func NewPlayback(sessionID string, deviceChan chan *nats.Msg, sleepMilliseconds uint) *Playback

func (*Playback) Write

func (r *Playback) Write(d []byte) (n int, err error)

type Recorder

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

func NewRecorder

func NewRecorder(ctx context.Context, sessionID string, store store.DataStore) *Recorder

func (*Recorder) Write

func (r *Recorder) Write(d []byte) (n int, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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