Documentation
¶
Index ¶
- func Clock(ctx context.Context) clock.Clock
- func WithClock(ctx context.Context, c clock.Clock) context.Context
- func WithDeadline(ctx context.Context, d time.Time) (context.Context, context.CancelFunc)
- func WithDeadlineOfClock(ctx context.Context, c clock.Clock, d time.Time) (context.Context, context.CancelFunc)
- func WithTimeout(ctx context.Context, timeout time.Duration) (context.Context, context.CancelFunc)
- func WithTimeoutOfClock(ctx context.Context, c clock.Clock, timeout time.Duration) (context.Context, context.CancelFunc)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithDeadline ¶
WithDeadline behaves exactly like context.WithDeadline but uses the clock from the context, if any, to determine which clock to use for the deadline.
This function delegates to WithDeadlineOfClock and has all of the caveats associated with it.
func WithDeadlineOfClock ¶
func WithDeadlineOfClock(ctx context.Context, c clock.Clock, d time.Time) (context.Context, context.CancelFunc)
WithDeadlineOfClock sets the given context deadline to be no later than the given time under the auspices of a particular clock.
This function delegates to context.WithDeadline if c == clock.RealClock. Otherwise, it is vastly less efficient than the standard library's context package equivalent because it does not have access to internal data associated with those contexts. In performance-sensitive applications, this function must be used with care.
This function does not set the clock in the context. To do that, use clockctx.WithDeadline(clockctx.WithClock(ctx, c), d) instead.
Note that using this method in combination with a clock that moves slower than wall time and downstream calls to the standard library context.WithDeadline/context.WithTimeout methods may result in strange, undesirable behavior.
func WithTimeout ¶
WithTimeout behaves exactly like context.WithTimeout but uses the clock from the context, if any, to determine which clock to use for the timeout.
This function delegates to WithTimeoutOfClock and has all of the caveats associated with it.
Types ¶
This section is empty.