streamer

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotSupported = errors.New("not supported")

Functions

func CloserCTX

func CloserCTX(ctx context.Context, fn func()) context.CancelFunc

CloserCTX calls fn if ctx is cancelled. Returns cancel function.

func GetLastBytes

func GetLastBytes(data []byte, last int) []byte

func NetReader

func NetReader(ctx context.Context, buff chan []byte, conn net.Conn, logger *zap.Logger) error

NetReader reads data from connection and put it into channel

func NewTimerWithDefault

func NewTimerWithDefault(duration time.Duration) *time.Timer

func StopTimer

func StopTimer(timer *time.Timer)

func TCPDialCtx

func TCPDialCtx(ctx context.Context, network, addr string) (net.Conn, error)

TCPDialCtx net.Dial version with context arg

func ThrowBadConsolePortException

func ThrowBadConsolePortException(lastRead []byte) error

func ThrowCmdTimeoutException

func ThrowCmdTimeoutException(lastRead []byte) error

func ThrowConsoleException

func ThrowConsoleException(lastRead []byte) error

func ThrowConsolePortIsBusyException

func ThrowConsolePortIsBusyException(lastRead []byte) error

func ThrowConsolePortIsLockedException

func ThrowConsolePortIsLockedException(lastRead []byte) error

func ThrowEOFException

func ThrowEOFException(lastRead []byte) error

func ThrowReadTimeoutException

func ThrowReadTimeoutException(lastRead []byte) error

Types

type BadConsolePortException

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

func (*BadConsolePortException) Error

func (e *BadConsolePortException) Error() string

type Chmod

type Chmod struct {
	UID int
	GID int
}

type CmdTimeoutException

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

func (*CmdTimeoutException) Error

func (e *CmdTimeoutException) Error() string

type Connector

type Connector interface {
	Init(context.Context) error
	GetCredentials() credentials.Credentials
	SetCredentialsInterceptor(func(credentials.Credentials) credentials.Credentials)
	SetTrace(trace.CB)
	SetReadTimeout(time.Duration) time.Duration
	Close()
	ReadTo(context.Context, expr.Expr) (ReadRes, error)
	Read(ctx context.Context, n int) ([]byte, error)
	Cmd(ctx context.Context, cmd string) (cmd.CmdRes, error)
	Write([]byte) error
	HasFeature(Const) bool
	Download(paths []string, recurse bool) (map[string]File, error)
	Upload(map[string]File) error
	InitAgentForward() error
}

type ConsoleException

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

func (*ConsoleException) Error

func (e *ConsoleException) Error() string

type ConsolePortIsBusyException

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

func (*ConsolePortIsBusyException) Error

type ConsolePortIsLockedException

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

func (*ConsolePortIsLockedException) Error

func (*ConsolePortIsLockedException) Is

func (m *ConsolePortIsLockedException) Is(target error) bool

type Const

type Const int
const (
	AutoLogin Const = iota
	Cmd
)

type EOFException

type EOFException struct {
	LastRead []byte
}

func (*EOFException) Error

func (m *EOFException) Error() string

func (*EOFException) Is

func (m *EOFException) Is(target error) bool

type File

type File struct {
	Data  []byte
	Mode  *os.FileMode
	Chmod *Chmod
	Err   error
}

func NewFile

func NewFile(data []byte, fileMode *os.FileMode, chmod *Chmod) File

func NewFileData

func NewFileData(data []byte) File

func NewFileError

func NewFileError(err error) File

type ReadRes

type ReadRes interface {
	GetBefore() []byte
	GetAfter() []byte
	GetMatchedGroups() map[string][]byte
	GetMatched() []byte
	GetPatternNo() int
}

type ReadResImpl

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

func NewReadResImpl

func NewReadResImpl(before, after []byte, matchedGroups map[string][]byte, matched []byte, patternNo int) ReadResImpl

func (ReadResImpl) GetAfter

func (m ReadResImpl) GetAfter() []byte

func (ReadResImpl) GetBefore

func (m ReadResImpl) GetBefore() []byte

func (ReadResImpl) GetMatched

func (m ReadResImpl) GetMatched() []byte

func (ReadResImpl) GetMatchedGroups

func (m ReadResImpl) GetMatchedGroups() map[string][]byte

func (ReadResImpl) GetPatternNo

func (m ReadResImpl) GetPatternNo() int

type ReadTimeoutException

type ReadTimeoutException struct {
	LastRead []byte
}

func (*ReadTimeoutException) Error

func (m *ReadTimeoutException) Error() string

func (*ReadTimeoutException) Is

func (m *ReadTimeoutException) Is(target error) bool

type ReadXRes

type ReadXRes struct {
	RetType   ReadXType
	ExprRes   ReadRes
	BytesRes  []byte
	ExprAfter []byte
}

func GenericReadX

func GenericReadX(ctx context.Context, inBuffer []byte, readCh chan []byte, readSize int, readTimeout time.Duration,
	regExpr expr.Expr, maxReadSize int, maxDuration time.Duration) (*ReadXRes, []byte, []byte, error)

GenericReadX reads from readCh till expr matched, exceeded time or read more than size. Returns error if nothing was read during readTimeout or ctx was Done readSize - maximum read size maxDuration - maximum time for reading regExpr - read till regex match Returns read res, left bytes, read bytes, error

func NewReadXRes

func NewReadXRes(retType ReadXType, bytesRes []byte, exprRes ReadRes, after []byte) *ReadXRes

type ReadXType

type ReadXType int64
const (
	Size ReadXType = iota
	Expr
	Timeout
	EOF
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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