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.
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
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the stream operation, used to signal cancellation. If the context is cancelled, any read errors are ignored. |
| r | io.Reader | The reader from which lines are read. This reader is expected to provide line-delimited data. |
| batchSize | int | The maximum number of log lines to include in a single batch before flushing. If set to 0 or less, a default batch size will be used. |
| flush | func([]*dataplane.LogLine) error | A callback function invoked for each batch of log lines. This function processes the collected lines and should return an error if the processing fails. |
Returns
| Type | Description |
|---|---|
error | Returns 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. |