Documentation ¶
Overview ¶
Service interfaces bases
Service interfaces bases
Index ¶
- type ServiceAdapter
- func (s ServiceAdapter) CopyData(ctx context.Context, sourceUrl string, destPath string) error
- func (s ServiceAdapter) CreateDirectories(ctx context.Context, dirs []string) error
- func (s ServiceAdapter) DeleteDirectory(ctx context.Context, dir string) error
- func (s ServiceAdapter) ForceReconnectWithBackoff(ctx context.Context) error
- func (s ServiceAdapter) PathExists(ctx context.Context, path string) (bool, error)
- func (s ServiceAdapter) PipeData(ctx context.Context, sourceUrl string, pipeCommand string) error
- func (s ServiceAdapter) Restart(ctx context.Context) error
- func (s ServiceAdapter) RunCmd(ctx context.Context, cmd string, args []string) (string, error)
- type ServiceAdapterInterface
- type ServiceInterface
- type ServiceState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ServiceAdapter ¶
type ServiceAdapter struct {
// contains filtered or unexported fields
}
func NewServiceAdapter ¶
func NewServiceAdapter(dut *lab_api.Dut, dutClient api.DutServiceClient, noReboot bool) ServiceAdapter
func (ServiceAdapter) CreateDirectories ¶
func (s ServiceAdapter) CreateDirectories(ctx context.Context, dirs []string) error
Create directories is a thin wrapper around an mkdir command. Done here as it is expected to be reused often by many services.
func (ServiceAdapter) DeleteDirectory ¶
func (s ServiceAdapter) DeleteDirectory(ctx context.Context, dir string) error
DeleteDirectory is a thin wrapper around an rm command. Done here as it is expected to be reused often by many services.
func (ServiceAdapter) ForceReconnectWithBackoff ¶
func (s ServiceAdapter) ForceReconnectWithBackoff(ctx context.Context) error
ForceReconnectWithBackoff is a thin wrapper around DUT service's ForceReconnectWithBackoff.
func (ServiceAdapter) PathExists ¶
PathExists determines if a path exists in a DUT
func (ServiceAdapter) PipeData ¶
PipeData uses the caching infrastructure to bring a file locally, allowing a user to pipe the result to any desired application.
type ServiceAdapterInterface ¶
type ServiceAdapterInterface interface { // RunCmd takes a command and argument and executes it remotely in the DUT, // returning the stdout as the string result and any execution error as the error. RunCmd(ctx context.Context, cmd string, args []string) (string, error) // Restart restarts a DUT (allowing cros-dut to reconnect for connection caching). Restart(ctx context.Context) error // PathExists is a simple wrapper for RunCmd for the sake of simplicity. If // the path exists True is returned, else False. An error implies a // a communication failure. PathExists(ctx context.Context, path string) (bool, error) // PipeData uses the caching infrastructure to bring an image into the lab. // Contrary to CopyData, the data here is pipeable to whatever is fed into // pipeCommand, rather than directly placed locally. PipeData(ctx context.Context, sourceUrl string, pipeCommand string) error // CopyData uses the caching infrastructure to copy a remote image to // the local path specified by destPath. CopyData(ctx context.Context, sourceUrl string, destPath string) error // DeleteDirectory is a simple wrapper for RunCmd for the sake of simplicity. DeleteDirectory(ctx context.Context, dir string) error // CreateDirectory is a simple wrapper for RunCmd for the sake of simplicity. // All directories specified in the array will be created. // As this uses "-p" option, subdirs are created regardless of whether parents // exist or not. CreateDirectories(ctx context.Context, dirs []string) error // ForceReconnectWithBackoff waits for the DUT to come back up/reconnect. ForceReconnectWithBackoff(ctx context.Context) error }
ServiceAdapters are used to interface with a DUT All methods here are proxies to cros-dut (with some additions for simplicity)
type ServiceInterface ¶
type ServiceInterface interface { // GetFirstState returns the first state in this state machine GetFirstState() ServiceState // CleanupOnFailure "undoes" the service execution to the extent possible, // removing temporary files, and, if feasible, reverting the run commands. // CleanupOnFailure function will be called if any ServiceState returns an // error when running Execute(). // |states| will include all ServiceStates that were run; naturally, all of // them but last one would have succeeded to Execute(). // |executionErr| is the error returned by Execute() of the last (failed) // ServiceState. CleanupOnFailure(states []ServiceState, executionErr error) error }
ServiceInterface represents the state machine for this specific service installation. It holds installation metadata and provides helpers, including the generator of the first state for that installation.
type ServiceState ¶
type ServiceState interface { // Execute Runs the state Execute(ctx context.Context) error // Next gets the next state in the state machine Next() ServiceState // Name gets the fully qualified name of this state Name() string }
ServiceState is a single state representation.
Directories ¶
Path | Synopsis |
---|---|
Package crosservice state machine construction and helper
|
Package crosservice state machine construction and helper |