package fxclock
Import Path
go.uber.org/fx/internal/fxclock (on go.dev)
Dependency Relation
imports 4 packages, and imported by 2 packages
Involved Source Files
clock.go
Package-Level Type Names (total 2)
Clock defines how Fx accesses time.
We keep the interface pretty minimal.
( Clock) Now() time.Time
( Clock) Since(time.Time) time.Duration
( Clock) Sleep(time.Duration)
( Clock) WithTimeout(context.Context, time.Duration) (context.Context, context.CancelFunc)
*Mock
github.com/benbjohnson/clock.Clock (interface)
*github.com/benbjohnson/clock.Mock
Clock : go.uber.org/dig/internal/digclock.Clock
Clock : github.com/hibiken/asynq/internal/timeutil.Clock
Clock : github.com/pion/stun.Clock
Clock : github.com/pion/stun/v3.Clock
Clock : github.com/quic-go/quic-go/internal/congestion.Clock
func go.uber.org/fx/internal/lifecycle.New(logger fxevent.Logger, clock Clock) *lifecycle.Lifecycle
var System
Mock is a fake source of time.
It implements standard time operations,
but allows the user to control the passage of time.
Use the [Add] method to progress time.
Add progresses time by the given duration.
Other operations waiting for the time to advance
will be resolved if they are within range.
Side effects of operations waiting for the time to advance
will take effect on a best-effort basis.
Avoid racing with operations that have side effects.
Panics if the duration is negative.
AwaitScheduled blocks until there are at least N
operations scheduled for the future.
Now reports the current time.
Since reports the time elapsed since t.
This is short for Now().Sub(t).
Sleep pauses the current goroutine for the given duration.
With the mock clock, this will freeze
until the clock is advanced with [Add] past the deadline.
WithTimeout returns a new context with a deadline of now + d.
When the deadline is passed, the returned context's Done channel is closed
and the context's Err method returns context.DeadlineExceeded.
If the cancel function is called before the deadline is passed,
the context's Err method returns context.Canceled.
*Mock : Clock
*Mock : go.uber.org/dig/internal/digclock.Clock
*Mock : github.com/hibiken/asynq/internal/timeutil.Clock
*Mock : github.com/pion/stun.Clock
*Mock : github.com/pion/stun/v3.Clock
*Mock : github.com/quic-go/quic-go/internal/congestion.Clock
func NewMock() *Mock
Package-Level Functions (only one)
NewMock builds a new mock clock
using the current actual time as the initial time.
Package-Level Variables (only one)
System is the default implementation of Clock based on real time.
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |