eows

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2017 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Overview

Package eows is used to Execute commands Over WebSocket

Package eows is used to Execute commands Over WebSocket

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DoneChan

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

type EmitExitCB

type EmitExitCB func(e *ExecOverWS, code int, err error)

EmitExitCB is the function callback used to emit exit proc code

type EmitOutputCB

type EmitOutputCB func(e *ExecOverWS, stdout, stderr string)

EmitOutputCB is the function callback used to emit data

type ExecOverWS

type ExecOverWS struct {
	Cmd      string           // command name to execute
	Args     []string         // command arguments
	SocketIO *socketio.Socket // websocket
	Sid      string           // websocket ID
	CmdID    string           // command ID

	// Optional fields
	Env            []string                // command environment variables
	CmdExecTimeout int                     // command execution time timeout
	Log            *logrus.Logger          // logger (nil if disabled)
	InputEvent     string                  // websocket input event name
	InputCB        OnInputCB               // stdin callback
	OutputCB       EmitOutputCB            // stdout/stderr callback
	ExitCB         EmitExitCB              // exit proc callback
	UserData       *map[string]interface{} // user data passed to callbacks
	OutSplit       SplitType               // split method to tokenize stdout/stderr
	// contains filtered or unexported fields
}

ExecOverWS .

func GetEows

func GetEows(cmdID string) *ExecOverWS

GetEows gets ExecOverWS object from command ID

func New

func New(cmd string, args []string, so *socketio.Socket, soID, cmdID string) *ExecOverWS

New creates a new instace of eows

func (*ExecOverWS) Signal

func (e *ExecOverWS) Signal(signal string) error

Signal sends a signal to the running command / process

func (*ExecOverWS) Start

func (e *ExecOverWS) Start() error

Start executes the command and redirect stdout/stderr into a WebSocket

type OnInputCB

type OnInputCB func(e *ExecOverWS, stdin string) (string, error)

OnInputCB is the function callback used to receive data

type SplitType added in v0.1.8

type SplitType uint8

SplitType Type of spliting method to tokenize stdout/stderr

const (
	// SplitLine Split line by line
	SplitLine SplitType = iota
	// SplitChar Split character by character
	SplitChar
)

Jump to

Keyboard shortcuts

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