Skip to main content

Stream

Reads lines from a reader, groups them into batches, and invokes a flush function for each batch. Batches are also flushed when the underlying reader has no buffered data available, preventing delays on partially-filled batches during idle periods.

def Stream(
ctx: context.Context,
r: io.Reader,
batchSize: int,
flush: func([]*dataplane.LogLine) error
) - > error

Reads lines from a given reader, groups them into batches, and invokes a flush function for each batch. Batches are also flushed when the underlying reader has no buffered data available to prevent callers from waiting indefinitely on partially-filled batches during idle periods.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for controlling the streaming operation, allowing for cancellation.
rio.ReaderThe reader from which log lines are read.
batchSizeintThe maximum number of log lines to include in a single batch before flushing. If less than or equal to 0, a default batch size is used.
flushfunc([]*dataplane.LogLine) errorA callback function invoked for each batch of log lines. It should handle the processing or writing of the batch.

Returns

TypeDescription
errorReturns nil on successful completion or if the context is cancelled. A non-EOF read error is returned only if the context has not been cancelled.