Documentation
¶
Index ¶
- func NewBatchedTeeReader[T any](args NewBatchedTeeReaderArgs[T]) core.Reader[[]T]
- func NewBatchedTeeWriter[T any](args NewBatchedTeeWriterArgs[T]) core.Writer[[]T]
- func NewStreamedTeeReader[T, U any](args NewStreamedTeeReaderArgs[T, U]) core.Reader[T]
- func NewStreamedTeeWriter[T, U any](args NewStreamedTeeWriterArgs[T, U]) core.Writer[T]
- type NewBatchedTeeReaderArgs
- type NewBatchedTeeWriterArgs
- type NewStreamedTeeReaderArgs
- type NewStreamedTeeWriterArgs
- type StatsBatched
- type StatsStreamed
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBatchedTeeReader ¶
func NewBatchedTeeReader[T any](args NewBatchedTeeReaderArgs[T]) core.Reader[[]T]
NewBatchedTeeReader returns a Reader[[]T] which pulls from args.Reader, while writing stats to args.Writer. It is similar to NewStreamedTeeReader but works with []T and writes stats containing "len" instead of "val". See args for details.
Note that the errs returned from this reader should be checked with errors.Is(...), they may be from both args.Reader (e.g io.EOF), args.Writer (e.g io.ErrClosedPipe) or both (wrap). If the err is from args.Writer, then the value read from args.Reader may be still valid.
Examples (interactive):
func NewBatchedTeeWriter ¶
func NewBatchedTeeWriter[T any](args NewBatchedTeeWriterArgs[T]) core.Writer[[]T]
NewBatchedTeeWriter returns a Writer[[]T] which writes into args.WriterVals while writing stats to args.WriterStats. See args for details.
Note that errs returned from this Writer should be checked with errors.Is(...), as they may be from args.WriterVals, args.WriterStats, or both. If the err is from args.WriterStats, then the value written to the returned Writer may have been written successfully.
Examples (interactive):
func NewStreamedTeeReader ¶
func NewStreamedTeeReader[T, U any](args NewStreamedTeeReaderArgs[T, U]) core.Reader[T]
NewStreamedTeeReader returns a Reader[T] which pulls from args.Reader, while writing stats to args.Writer. See args for details.
Note that the errs returned from this reader should be checked with errors.Is(...), they may be from both args.Reader (e.g io.EOF), args.Writer (e.g io.ErrClosedPipe) or both (wrap). If the err is from args.Writer, then the value read from args.Reader may be still valid.
Examples (interactive):
func NewStreamedTeeWriter ¶
func NewStreamedTeeWriter[T, U any](args NewStreamedTeeWriterArgs[T, U]) core.Writer[T]
NewStreamedTeeWriter returns a Writer[T] which writes into args.WriterVals while writing stats to args.WriterStats. See args for details.
Note that errs returned from this Writer should be checked with errors.Is(...), as they may be from args.WriterVals, args.WriterStats, or both. If the err is from args.WriterStats, then the value written to the returned Writer may have been written successfully.
Examples (interactive):
Types ¶
type NewBatchedTeeReaderArgs ¶
type NewBatchedTeeReaderArgs[T any] struct { // Reader is what the func reads from. On nil, the func simply returns // a core.ReaderImpl[T], making it pointless. If it returns io.EOF, // then the returned reader will skip internal logic and also return io.EOF. Reader core.Reader[[]T] // Writer is where stats are written. On nil, stats are not written anywhere, // and the func simply passes along values from Reader. Errors coming from // here will be wrapped with any err returned from Reader using errors.Join. Writer core.Writer[StatsBatched] // Tag will be set to StatsStreamed.Tag which are sent to the Writer. If // empty, the value will be set to "<unset>". Tag string // CtxKeys is used to extract values from the ctx given to the returned // Reader. These k:v pairs are set to StatsStreamed.CtxMap. CtxKeys []string }
type NewBatchedTeeWriterArgs ¶
type NewBatchedTeeWriterArgs[T any] struct { // WriterVals is what the returned Writer writes to. On nil, the func simply // returns a core.WriterImpl[[]T]{}, making it pointless. If it returns an // io.ErrClosedPipe, then the returned Writer returns early with that err. WriterVals core.Writer[[]T] // WriterStats is where stats are written. On nil, stats are not written // anywhere, and the returned Writer will simply pass along values to // WriterVals. Errors coming from here will be wrapped with any error // returned from WriterVals using errors.Join. WriterStats core.Writer[StatsBatched] // Tag will be set to StatsStreamed.Tag which are sent to the Writer. If // empty, the value will be set to "<unset>". Tag string // CtxKeys is used to extract values from the ctx given to the returned // Reader. These k:v pairs are set to StatsStreamed.CtxMap. CtxKeys []string }
type NewStreamedTeeReaderArgs ¶
type NewStreamedTeeReaderArgs[T, U any] struct { // Reader is what the func reads from. On nil, the func simply returns // a core.ReaderImpl[T], making it pointless. If it returns io.EOF, // then the returned reader will skip internal logic and also return io.EOF. Reader core.Reader[T] // Writer is where stats are written. On nil, stats are not written anywhere, // and the func simply passes along values from Reader. Errors coming from // here will be wrapped with any err returned from Reader using errors.Join. Writer core.Writer[StatsStreamed[U]] // Tag will be set to StatsStreamed.Tag which are sent to the Writer. If // empty, the value will be set to "<unset>". Tag string // Fmt defines what to set to StatsStreamed.Val which are sent to the Writer. // On nil, StatsStreamed.Val is set to the zero value of U. Fmt func(T) U // CtxKeys is used to extract values from the ctx given to the returned // Reader. These k:v pairs are set to StatsStreamed.CtxMap. CtxKeys []string }
type NewStreamedTeeWriterArgs ¶
type NewStreamedTeeWriterArgs[T, U any] struct { // WriterVals is what the returned Writer writes to. On nil, the func simply // returns a core.WriterImpl[T]{}, making it pointless. If it returns an // io.ErrClosedPipe, then the returned Writer returns early with that err. WriterVals core.Writer[T] // WriterStats is where stats are written. On nil, stats are not written // anywhere, and the returned Writer will simply pass along values to // WriterVals. Errors coming from here will be wrapped with any error // returned from WriterVals using errors.Join. WriterStats core.Writer[StatsStreamed[U]] // Tag will be set to StatsStreamed.Tag which are sent to the Writer. If // empty, the value will be set to "<unset>". Tag string // Fmt defines what to set to StatsStreamed.Val which are sent to the Writer. // On nil, StatsStreamed.Val is set to the zero value of U. Fmt func(T) U // CtxKeys is used to extract values from the ctx given to the returned // Reader. These k:v pairs are set to StatsStreamed.CtxMap. CtxKeys []string }