Documentation
¶
Index ¶
- type Clock
- type JumperClock
- func (c *JumperClock) Back()
- func (c *JumperClock) Freeze(t time.Time)
- func (c *JumperClock) Jump(t time.Time)
- func (c *JumperClock) NewDefaultTimeMachine() TimeMachine
- func (c *JumperClock) Now() time.Time
- func (c *JumperClock) Scale(s int) error
- func (c *JumperClock) SetTimeMachine(t TimeMachine)
- func (c *JumperClock) Since(t time.Time) time.Duration
- func (c *JumperClock) Sleep(d time.Duration)
- type RealClock
- type TimeMachine
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clock ¶
Clock is an interface that allows you to a create different implementions for testing purposes
type JumperClock ¶
type JumperClock struct {
// contains filtered or unexported fields
}
JumperClock is a Go implementation of but does not use package globals https://github.com/travisjeffery/timecop Instantiate with New()
func (*JumperClock) Back ¶
func (c *JumperClock) Back()
Back returns you to the present (future? since you started) Does not change the TimeMachine
func (*JumperClock) Freeze ¶
func (c *JumperClock) Freeze(t time.Time)
Freeze ensures time doesn't progress forward You can still move time by freezing again with a new time or by using Travel
func (*JumperClock) Jump ¶
func (c *JumperClock) Jump(t time.Time)
Jump sets the clock to the desired time Compatible with Freeze (will remain frozen if previously frozen)
func (*JumperClock) NewDefaultTimeMachine ¶
func (c *JumperClock) NewDefaultTimeMachine() TimeMachine
NewDefaultTimeMachine is what's used to enable scaling and freezing
func (*JumperClock) Scale ¶
func (c *JumperClock) Scale(s int) error
Scale sets the time scale multiplier If set to 0, freezes the clock instead
func (*JumperClock) SetTimeMachine ¶
func (c *JumperClock) SetTimeMachine(t TimeMachine)
SetTimeMachine sets TimeMachine, a function that controls how time works! It also resets the clock according to Back()
func (*JumperClock) Since ¶
func (c *JumperClock) Since(t time.Time) time.Duration
Since returns the time elapsed since t. It is shorthand for .Now().Sub(t).
func (*JumperClock) Sleep ¶
func (c *JumperClock) Sleep(d time.Duration)
Sleep is similar to jump, except that it takes a duration
type RealClock ¶
type RealClock struct{}
RealClock implements the standard lib only functions relevant for this codebase
type TimeMachine ¶
TimeMachine is a function that gets called each time Now() is called The default machine allows the usage of freeze, scale and jump features of Jumper. This allows you to completely switch out the functionality