clock

package
v0.0.0-...-d03d5e3 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Suspendable

type Suspendable interface {
	Suspend()
	Resume()
}

Suspendable is an interface type of the methods of SuspendableClock that are used by NewSuspendingBlobAccess() and NewSuspendingDirectoryFetcher().

type SuspendableClock

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

SuspendableClock is a decorator for Clock that allows Timers and Contexts with timeouts to be suspended temporarily. This decorator can, for example, be used to let FUSE-based workers compensate the execution timeout of build actions with time spent performing BlobAccess reads.

func NewSuspendableClock

func NewSuspendableClock(base clock.Clock, maximumSuspension, timeoutThreshold time.Duration) *SuspendableClock

NewSuspendableClock creates a new SuspendableClock.

The maximumSuspension argument denotes the maximum amount of time Timers and Contexts with timeouts may be suspended. This prevents users from bypassing timeouts when creating access patterns that cause the clock to be suspended excessively.

func (*SuspendableClock) NewContextWithTimeout

func (c *SuspendableClock) NewContextWithTimeout(parent context.Context, d time.Duration) (context.Context, context.CancelFunc)

NewContextWithTimeout creates a Context object that automatically cancels itself after a certain amount of time has passed, taking suspensions of the Clock into account.

func (*SuspendableClock) NewTimer

func (c *SuspendableClock) NewTimer(d time.Duration) (clock.Timer, <-chan time.Time)

NewTimer creates a channel that publishes the time of day at a point of time in the future, taking suspension of the Clock into account.

func (*SuspendableClock) Now

func (c *SuspendableClock) Now() time.Time

Now returns the current time of day.

func (*SuspendableClock) Resume

func (c *SuspendableClock) Resume()

Resume the Clock, thereby causing all active Timer and Context objects to continue processing.

func (*SuspendableClock) Suspend

func (c *SuspendableClock) Suspend()

Suspend the Clock, thereby causing all active Timer and Context objects to not trigger (except if the maximum suspension duration is reached).

Clocks can be suspended multiple times. The clock will only continue to run if Resume() is called an equal number of times.

type UnsuspendedDurationKey

type UnsuspendedDurationKey struct{}

UnsuspendedDurationKey instances can be provided to Context.Value() to obtain the total amount of time a SuspendableClock associated with the Context object was not suspended, since the creation of the Context.

Jump to

Keyboard shortcuts

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