Documentation
¶
Overview ¶
Package contextutil contains types and utilities for working with contexts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Constructor ¶
type Constructor interface {
// New returns a new context based on parent as well as a cancel function.
// parent, ctx, and cancel must not be nil.
New(parent context.Context) (ctx context.Context, cancel context.CancelFunc)
}
Constructor is an interface for constructing contexts with deadlines, e.g. for request contexts.
type EmptyConstructor ¶
type EmptyConstructor struct{}
EmptyConstructor is the implementation of the Constructor interface that returns the parent context and an empty context.CancelFunc.
func (EmptyConstructor) New ¶
func (EmptyConstructor) New( parent context.Context, ) (ctx context.Context, cancel context.CancelFunc)
New implements the Constructor interface for EmptyConstructor.
type TimeoutConstructor ¶
type TimeoutConstructor struct {
// contains filtered or unexported fields
}
TimeoutConstructor is an implementation of the Constructor interface that returns a context with the given timeout.
func NewTimeoutConstructor ¶
func NewTimeoutConstructor(timeout time.Duration) (c *TimeoutConstructor)
NewTimeoutConstructor returns a new properly initialized *TimeoutConstructor.
func (*TimeoutConstructor) New ¶
func (c *TimeoutConstructor) New( parent context.Context, ) (ctx context.Context, cancel context.CancelFunc)
New implements the Constructor interface for *TimeoutConstructor. It returns a context with its timeout and the corresponding cancellation function.