Documentation ¶
Overview ¶
Package netTime provides a custom time function that should provide the current accurate time used by the network from a custom time service.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func After ¶
After waits for the duration to elapse and then sends the current time on the returned channel. It is equivalent to NewTimer(d).C. Refer to time.After for more information.
func SetOffset ¶
SetOffset sets the internal offset variable atomically. All calls to Now will have this offset added to the result. Negative offsets are accepted and will reduce the result of the call to Now.
func SetTimeSource ¶
func SetTimeSource(nowFunc TimeSource)
SetTimeSource sets Now to a custom source. All calls to Now will use this TimeSource. Note that this is in-memory, so any restart will require that this function be recalled.
Types ¶
type TimeSource ¶
type TimeSource interface {
NowMs() int64
}
TimeSource is an interface which matches a time service that may be used to set Now.
type Timer ¶
The Timer type represents a single event. When the Timer expires, the current time will be sent on C, unless the Timer was created by AfterFunc. A Timer must be created with NewTimer or AfterFunc.
func AfterFunc ¶
AfterFunc waits for the duration to elapse and then calls f in its own goroutine. It returns a Timer that can be used to cancel the call using its Stop method. Refer to time.AfterFunc for more information.
func NewTimer ¶
NewTimer creates a new Timer that will send the current time on its channel after at least duration d. This wraps a time.Timer to provide a timer accurate to the set time source.