module

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package module provides a plugin system for the DUT package. Modules are the building blocks of a command and host the actual implementation of the steps that are executed on a device-under-test (DUT). The core of the plugin system is the Module interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(mod Info)

Register registers a module for use in dutagent.

Types

type Info

type Info struct {
	// ID is the unique identifier of the module.
	// It is used to reference the module in the dutagent configuration.
	ID string
	// New is the factory function that creates a new instance of the module.
	New func() Module
}

Info holds the information required to register a module.

type Module

type Module interface {
	// Help returns a formatted string with the capabilities of the module.
	// It provides any user information required to interact with the module.
	Help() string
	// Init is called once when the dutagent services is started.
	// It's a good place to establish connections or allocate resources and check whether
	// the module is configured functional
	Init() error
	// Deinit is called when the module is unloaded by dutagent or an internal error occurs.
	// It is used to clean up any resources that were allocated during the Init phase and
	// shall guarantee a graceful shutdown of the service
	Deinit() error
	// Run is the entry point and executes the module with the given arguments.
	Run(ctx context.Context, s Session, args ...string) error
}

Module is a building block of a command running on a device-under-test (DUT). Implementations of this interface are the actual steps that are executed on a DUT.

func New

func New(id string) (Module, error)

New creates a new instance of a former registered module by its ID.

type Session

type Session interface {
	Print(text string)
	Console() (stdin io.Reader, stdout, stderr io.Writer)
	RequestFile(name string) (io.Reader, error)
	SendFile(name string, r io.Reader) error
}

Session provides an environment / a context for a module. Via the Session interface, modules can interact with the client during execution.

Directories

Path Synopsis
Dummy module implementation.
Dummy module implementation.

Jump to

Keyboard shortcuts

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