iotest

package
v0.24.39 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: Apache-2.0, MIT Imports: 4 Imported by: 0

Documentation

Overview

Package iotest provides io related test functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FlushedResponseWriter

type FlushedResponseWriter interface {
	http.ResponseWriter
	http.Flusher
	Unwrap() http.ResponseWriter
}

type FlushedWriter

type FlushedWriter interface {
	io.Writer
	http.Flusher
}

type SlowReader

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

func NewSlowReader

func NewSlowReader(r io.Reader, d time.Duration) *SlowReader

NewSlowReader creates a new slowReader wrapping the given io.Reader with a delay after each byte.

func (*SlowReader) Read

func (sr *SlowReader) Read(p []byte) (n int, err error)

Read implements the io.Reader interface. It reads one byte at a time from the underlying reader, sleeps for the specified Delay, and populates the provided buffer 'p'.

type SlowResponseWriter

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

SlowResponseWriter is a FlushedResponseWriter to test write timeout specific test scenarios.

func NewSlowResponseWriter

func NewSlowResponseWriter(rw http.ResponseWriter, d time.Duration) *SlowResponseWriter

NewSlowResponseWriter creates a new SlowResponseWriter wrapping the given http.ResponseWriter with a delay after each byte.

func (*SlowResponseWriter) Flush

func (sw *SlowResponseWriter) Flush()

func (*SlowResponseWriter) Header

func (sw *SlowResponseWriter) Header() http.Header

func (*SlowResponseWriter) Unwrap

func (sw *SlowResponseWriter) Unwrap() http.ResponseWriter

func (*SlowResponseWriter) Write

func (sw *SlowResponseWriter) Write(p []byte) (n int, err error)

func (*SlowResponseWriter) WriteHeader

func (sw *SlowResponseWriter) WriteHeader(i int)

type SlowWriter

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

func NewSlowWriter

func NewSlowWriter(w io.Writer, d time.Duration) *SlowWriter

func (*SlowWriter) Flush

func (sw *SlowWriter) Flush()

func (*SlowWriter) Write

func (sw *SlowWriter) Write(p []byte) (n int, err error)

Write implements the io.Writer interface. It writes one byte at a time to the underlying writer, sleeps for the specified delay, reading from buffer 'p'. Each write will be followed by a flush.

type TimeoutWriter

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

func NewTimeoutWriter

func NewTimeoutWriter(w io.Writer, attempt int) *TimeoutWriter

func (*TimeoutWriter) Write

func (tw *TimeoutWriter) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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