session

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAckTimeout               = fmt.Errorf("timed out waiting for ack")
	ErrHeartbeatTimeout         = fmt.Errorf("timed out waiting for heartbeat reply")
	ErrUnimplementedMessageType = fmt.Errorf("unimplemented message type")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// NetTimeout is the timeout for network operations,
	// eg. reading and writing to a socket.
	NetTimeout *time.Duration
	// AckTimeout is the timeout for waiting for an ack reply.
	AckTimeout *time.Duration
	// HeartbeatInterval is the interval between sending heartbeats.
	HeartbeatInterval *time.Duration
	// HeartbeatTimeout is the timeout for waiting for a heartbeat reply.
	HeartbeatTimeout *time.Duration
	// MessageHandlers is a map of message handlers for specific message types.
	MessageHandlers map[string]MessageHandler
}

Config is the configuration for a session.

type MessageHandler

type MessageHandler func(message.Message) (sendAck bool, err error)

MessageHandler is a function that handles messages.

type Session

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

Session represents an shell session.

func NewSession

func NewSession(ctx context.Context, logger *slog.Logger,
	ws *websocket.Conn, conf *Config) (*Session, error)

NewSession creates a new shell session.

func (*Session) Close

func (s *Session) Close() error

Close closes the session.

func (*Session) Read

func (s *Session) Read(b []byte) (n int, err error)

Read reads data from the session

func (*Session) SetReadDeadline

func (s *Session) SetReadDeadline(t time.Time) error

SetReadDeadline sets the read deadline on the session.

func (*Session) SetWriteDeadline

func (s *Session) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the write deadline on the session.

func (*Session) Wait

func (s *Session) Wait() error

Wait waits for the session to complete (including all background tasks).

func (*Session) Write

func (s *Session) Write(b []byte) (n int, err error)

Write writes data to the session.

func (*Session) WriteControl

func (s *Session) WriteControl(msg message.Message) error

WriteControl sends a control message and waits for an acknowledgment.

Jump to

Keyboard shortcuts

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