Documentation ¶
Index ¶
- Variables
- func Filter[T any](slice []T, predicate func(T) bool) []T
- func Min[T Number](a T, b T) T
- func NowXGenerator(line []float64) float64
- type CsvStringReader
- type DataBroadcaster
- type DataRow
- type DataRowReader
- type HttpServer
- type Metadata
- type Number
- type RelaxedStringReader
- type StreamEndedMessage
- type StringReader
- type TextToDataRowReader
- type ThreadUnsafeRing
- type WesplotOptions
Constants ¶
This section is empty.
Variables ¶
var Version string = "?? (source-build)"
Functions ¶
func NowXGenerator ¶
Generates the current unix timestamp in seconds.
Types ¶
type CsvStringReader ¶
type CsvStringReader struct {
// contains filtered or unexported fields
}
This implements a StringDataReader and reads an io.Reader using the Golang csv module. This means the input data must strictly conform to CSV data. If the input data is not exactly CSV (for example separated by one or more spaces), use the RelaxedStringReader.
func NewCsvStringReader ¶
func NewCsvStringReader(input io.Reader) *CsvStringReader
type DataBroadcaster ¶
type DataBroadcaster struct {
// contains filtered or unexported fields
}
func NewDataBroadcaster ¶
func NewDataBroadcaster(input DataRowReader, bufferCapacity int, teeMode bool) *DataBroadcaster
func (*DataBroadcaster) DeregisterChannel ¶
func (d *DataBroadcaster) DeregisterChannel(ctx context.Context, c chan<- DataRow)
Deregister a channel to get data updates. Called when a websocket client disconnects or when the input stream closes. Note: the channel shouldn't be closed until this method returns (if the input is still open), as it may cause panics otherwise.
- ctx: is the HTTP call context. - c: is the channel to send data on. This should be the same channel as the one passed to RegisterChannel to successfully deregister.
This method will panic if c is not registered. This indicates a programming error.
func (*DataBroadcaster) RegisterChannel ¶
func (d *DataBroadcaster) RegisterChannel(ctx context.Context, c chan<- DataRow)
Register a new channel. Called from the HTTP server when a new websocket connection is initiated.
- ctx: is the HTTP call context. - c: is the channel to send data on. This should be a buffered channel to ensure the DataBroadcaster is not blocked, as if any channel is blocked, everything is blocked.
func (*DataBroadcaster) Start ¶
func (d *DataBroadcaster) Start(ctx context.Context)
func (*DataBroadcaster) Wait ¶
func (d *DataBroadcaster) Wait()
type DataRowReader ¶
When Read is called, return the DataRow.
type HttpServer ¶
type HttpServer struct {
// contains filtered or unexported fields
}
func NewHttpServer ¶
func NewHttpServer(dataBroadcaster *DataBroadcaster, host string, port uint16, metadata Metadata, flushInterval time.Duration) *HttpServer
func (*HttpServer) Run ¶
func (s *HttpServer) Run() error
type Metadata ¶
type Metadata struct { WindowSize int XIsTimestamp bool RelativeStart bool WesplotOptions WesplotOptions }
type Number ¶
type Number interface { constraints.Float | constraints.Integer }
type RelaxedStringReader ¶
type RelaxedStringReader struct {
// contains filtered or unexported fields
}
This is a more relaxed reader that can split on spaces or commas. However, it does not follow string CSV formatting. This is the default.
func NewRelaxedStringReader ¶
func NewRelaxedStringReader(input io.Reader) *RelaxedStringReader
type StreamEndedMessage ¶
type StringReader ¶
When Read is called, return an array of strings which are the columns.
type TextToDataRowReader ¶
type TextToDataRowReader struct { // The input reader object (either CsvStringReader or RelaxedStringReader) Input StringReader // The x column index. If this is <0, X is generated via XGenerator, which // corresponds to the current time stamp in seconds. Note this column // will be put into DataRow.X while the rest of the row except this column // will be put into DataRow.Ys. XIndex int // The generator function. Defaults to NowXGenerator. XGenerator func([]float64) float64 // The labels of the columns excluding the X column. Columns []string // If the input row has a different length than Columns, ignore the row. ExpectExactColumnCount bool }
Creates a DataRowReader based on text input. Unrecognized/unparsable lines will be ignored and logged via warnings.
func (*TextToDataRowReader) ColumnNames ¶
func (r *TextToDataRowReader) ColumnNames() []string
type ThreadUnsafeRing ¶
type ThreadUnsafeRing[T any] struct { // contains filtered or unexported fields }
A terrible implementation of a ring, based on the Golang ring which is not thread-safe nor offers a nice API.
I can't believe there are no simple ring buffer data structure in Golang, with generics.
func NewRing ¶
func NewRing[T any](capacity int) *ThreadUnsafeRing[T]
func (*ThreadUnsafeRing[T]) Push ¶
func (r *ThreadUnsafeRing[T]) Push(data T)
func (*ThreadUnsafeRing[T]) ReadAllOrdered ¶
func (r *ThreadUnsafeRing[T]) ReadAllOrdered() []T