ws

package
v0.0.0-...-06858c0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const CodeOceanOutputWriterBufferSize = 64

CodeOceanOutputWriterBufferSize defines the number of messages.

View Source
const CodeOceanToRawReaderBufferSize = 1024

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection interface {
	WriteMessage(messageType int, data []byte) error
	Close() error
	NextReader() (messageType int, r io.Reader, err error)
	CloseHandler() func(code int, text string) error
	SetCloseHandler(handler func(code int, text string) error)
}

Connection is an internal interface for websocket.Conn in order to mock it for unit tests.

type ConnectionMock

type ConnectionMock struct {
	mock.Mock
}

ConnectionMock is an autogenerated mock type for the Connection type

func NewConnectionMock

func NewConnectionMock(t mockConstructorTestingTNewConnectionMock) *ConnectionMock

NewConnectionMock creates a new instance of ConnectionMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*ConnectionMock) Close

func (_m *ConnectionMock) Close() error

Close provides a mock function with given fields:

func (*ConnectionMock) CloseHandler

func (_m *ConnectionMock) CloseHandler() func(int, string) error

CloseHandler provides a mock function with given fields:

func (*ConnectionMock) NextReader

func (_m *ConnectionMock) NextReader() (int, io.Reader, error)

NextReader provides a mock function with given fields:

func (*ConnectionMock) SetCloseHandler

func (_m *ConnectionMock) SetCloseHandler(handler func(int, string) error)

SetCloseHandler provides a mock function with given fields: handler

func (*ConnectionMock) WriteMessage

func (_m *ConnectionMock) WriteMessage(messageType int, data []byte) error

WriteMessage provides a mock function with given fields: messageType, data

type WebSocketReader

type WebSocketReader interface {
	io.Reader
	io.Writer
	Start()
	Stop()
}

WebSocketReader is an interface that is intended for providing abstraction around reading from a WebSocket. Besides, io.Reader, it also implements io.Writer. The Write method is used to inject data into the WebSocket stream.

func NewCodeOceanToRawReader

func NewCodeOceanToRawReader(wsCtx, executorCtx context.Context, connection Connection) WebSocketReader

type WebSocketWriter

type WebSocketWriter interface {
	StdOut() io.Writer
	StdErr() io.Writer
	Close(info *runner.ExitInfo)
}

WebSocketWriter is an interface that defines which data is required and which information can be passed.

func NewCodeOceanOutputWriter

func NewCodeOceanOutputWriter(ctx context.Context, connection Connection, done context.CancelFunc) WebSocketWriter

NewCodeOceanOutputWriter provides an codeOceanOutputWriter for the time the context ctx is active. The codeOceanOutputWriter handles all the messages defined in the websocket.schema.json (start, timeout, stdout, ...).

Jump to

Keyboard shortcuts

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