Documentation
¶
Overview ¶
Package timeout provides support for contexts with extendable timeouts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler corresponds to a context created by the New function. It provides utility methods for extending the underlying context timeout during operations.
func New ¶
New returns a new context that is automatically cancelled after the given timeout duration. The timeout duration can be extended using the Reset and ResetFor methods on the returned Handler.
func (*Handler) Cancel ¶
func (h *Handler) Cancel()
Cancel stops the underlying timer for the timeout, and cancels the associated context.
func (*Handler) Copy ¶
func (h *Handler) Copy(dst io.Writer, src io.Reader, buf []byte, d time.Duration) (written int64, err error)
Copy copies from src to dst until either EOF is reached on src or an error occurs. It returns the number of bytes copied and the first error encountered while copying, if any.
After each successful read, it keeps extending the timeout by the given duration d.
func (*Handler) ExpireAfter ¶
ExpireAfter resets the context to timeout after duration d.
func (*Handler) ReadAll ¶
ReadAll reads from r until an error or EOF and returns the data it read. A successful call returns err == nil, not err == EOF. Because ReadAll is defined to read from src until EOF, it does not treat an EOF from Read as an error to be reported.
After each successful read, it keeps extending the timeout by the given duration d.