websocket

package
v0.0.0-...-b4828b3 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBufferSize         = 4096
	DefaultChunkBytes         = 160000
	DefaultMaxBytes           = 1440000
	DefaultTrimBytes          = 1120000
	DefaultProcessingInterval = 2000
	DefaultIsStream           = false
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	trigger.Configuration
	WebSocketAddr      string        `mapstructure:"websocket_addr"`
	BufferSize         int           `mapstructure:"buffer_size"`
	ChunkBytes         int           `mapstructure:"chunk_bytes"`
	MaxBytes           int           `mapstructure:"max_bytes"`
	TrimBytes          int           `mapstructure:"trim_bytes"`
	ProcessingInterval time.Duration `mapstructure:"processing_interval"`
	IsStream           bool          `mapstructure:"is_stream"`
}

func NewConfiguration

func NewConfiguration(id string,
	triggerConfiguration *functionconfig.Trigger,
	runtimeConfiguration *runtime.Configuration) (*Configuration, error)

type DataProcessorDiscrete

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

DataProcessorDiscrete processes independent WebSocket messages. Each Push replaces the previous value, and latest data is periodically emitted as an Event.

func NewDataProcessorDiscrete

func NewDataProcessorDiscrete(processingInterval time.Duration) *DataProcessorDiscrete

func (*DataProcessorDiscrete) Output

func (dp *DataProcessorDiscrete) Output() <-chan *Event

func (*DataProcessorDiscrete) Push

func (dp *DataProcessorDiscrete) Push(data []byte)

func (*DataProcessorDiscrete) Start

func (dp *DataProcessorDiscrete) Start()

func (*DataProcessorDiscrete) Stop

func (dp *DataProcessorDiscrete) Stop()

type DataProcessorStream

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

DataProcessorStream aggregates incoming byte stream into fixed-size chunks, keeps a rolling buffer, and periodically emits snapshots as Events.

func NewDataProcessorStream

func NewDataProcessorStream(
	chunkBytes,
	maxBytes,
	trimBytes int,
) *DataProcessorStream

func (*DataProcessorStream) Output

func (dp *DataProcessorStream) Output() <-chan *Event

func (*DataProcessorStream) Push

func (dp *DataProcessorStream) Push(data []byte)

append raw incoming data and convert it into fixed-size chunks. Chunks are appended to rolling buffer.

func (*DataProcessorStream) Start

func (dp *DataProcessorStream) Start(processingInterval time.Duration)

func (*DataProcessorStream) Stop

func (dp *DataProcessorStream) Stop()

type Event

type Event struct {
	nuclio.AbstractEvent
	// contains filtered or unexported fields
}

Event wraps a single message received over WebSocket

func (*Event) GetBody

func (e *Event) GetBody() []byte

GetBody returns the WebSocket message data

func (*Event) GetContentType

func (e *Event) GetContentType() string

GetContentType returns the content type of the WebSocket message

func (*Event) GetField

func (e *Event) GetField(key string) interface{}

GetField returns an attribute by key

func (*Event) GetFieldByteSlice

func (e *Event) GetFieldByteSlice(key string) []byte

GetFieldByteSlice returns an attribute value as a byte slice

func (*Event) GetFieldInt

func (e *Event) GetFieldInt(key string) (int, error)

GetFieldInt returns an attribute value as an int

func (*Event) GetFieldString

func (e *Event) GetFieldString(key string) string

GetFieldString returns an attribute value as a string

func (*Event) GetFields

func (e *Event) GetFields() map[string]interface{}

GetFields returns all attributes

func (*Event) GetHeader

func (e *Event) GetHeader(key string) interface{}

GetHeader returns a header value as an interface{}

func (*Event) GetHeaderByteSlice

func (e *Event) GetHeaderByteSlice(key string) []byte

GetHeaderByteSlice returns a header value as a byte slice

func (*Event) GetHeaderInt

func (e *Event) GetHeaderInt(key string) (int, error)

GetHeaderInt returns a header value as an int

func (*Event) GetHeaderString

func (e *Event) GetHeaderString(key string) string

GetHeaderString returns a header value as a string

func (*Event) GetHeaders

func (e *Event) GetHeaders() map[string]interface{}

GetHeaders returns all attributes as headers

func (*Event) GetMethod

func (e *Event) GetMethod() string

GetMethod returns "websocket" as the method

func (*Event) GetPath

func (e *Event) GetPath() string

GetPath returns empty path (not applicable for WebSocket)

func (*Event) GetTimestamp

func (e *Event) GetTimestamp() time.Time

GetTimestamp returns the packet timestamp

Jump to

Keyboard shortcuts

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