telex

package module
v0.0.0-...-33cf3d0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

package telex executes process and streams process output to clients

Index

Constants

View Source
const (
	StatusInvalid = iota
	StatusRunning
	StatusCompleted
	StatusFailed
	StatusKilled
)

Process status codes

View Source
const (
	StreamStdout
	StreamStderr
)

Output stream types

Variables

This section is empty.

Functions

func GetOutputStream

func GetOutputStream(cache *JobCache, ctx context.Context, handle string, streamType int) (<-chan string, error)

GetOutputStream returns channel the client can read process output from. The channel will be closed when all output of the process is delivered. Client can cancel the stream using context. It is a responsibility of the caller to check whether process belongs to the user.

func Kill

func Kill(cache *JobCache, handle string) error

Kill kills the process, if it is running. It is a responsibility of the caller to check whether process belongs to the user.

func StartProcess

func StartProcess(cache *JobCache, cmdLine string, user string, mountPoint ...string) (string, error)

StartProcess starts execution of provided command, returns process handle or error.

func Status

func Status(cache *JobCache, handle string) (status int, owner string, exitcode int, err error)

Status returns the status, owner and exitcode of the process. It is a responsibility of the caller to check whether process belongs to the user.

Types

type JobCache

type JobCache struct {
	sync.RWMutex // mutex to allow safely adding new records to runLog
	// contains filtered or unexported fields
}

func New

func New() *JobCache

Jump to

Keyboard shortcuts

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