mirror of
https://github.com/temporalio/temporal.git
synced 2026-08-31 11:01:53 -07:00
## What changed?
<!-- Describe what has changed in this PR -->
Remove license header from every file. Because it is really hard to
follow in this PR here is the summary:
1. License header is removed from all `.go` and `.proto` files
:fireworks::fireworks:🎆.
2. `LICENSE` file in the root directory has only Temporal and Uber
copyrights.
3. 5 other `LICENSE` files added to the packages which have copyrights
different from Temporal and Uber: Datadog, Xargin, "Mat Ryer, Tyler
Bunnell and contributors".
4. `license_file` flag is removed from all code generation tools.
5. `copyright_file` flag is removed from `go:generate mockgen`
directive.
6. All copyright related targets are removed from `Makefile`.
7. Updated Temporal copyright year to 2025 everywhere.
## Why?
<!-- Tell your future self why have you made these changes -->
I double checked with legal department that it is not needed to have
license header in every file. One file per repo is enough. I put all
copyrights to the root `LICENSE` file and removed header from all other
files. Also updated tools and `Makefile`.
57 lines
1.8 KiB
Go
57 lines
1.8 KiB
Go
// Package clock provides extensions to the [time] package.
|
|
package clock
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
type (
|
|
// TimeSource is an interface to make it easier to test code that uses time.
|
|
TimeSource interface {
|
|
Now() time.Time
|
|
Since(t time.Time) time.Duration
|
|
AfterFunc(d time.Duration, f func()) Timer
|
|
NewTimer(d time.Duration) (<-chan time.Time, Timer)
|
|
}
|
|
// Timer is a timer returned by TimeSource.AfterFunc. Unlike the timers returned by [time.NewTimer] or time.Ticker,
|
|
// this timer does not have a channel. That is because the callback already reacts to the timer firing.
|
|
Timer interface {
|
|
// Reset changes the expiration time of the timer. It returns true if the timer had been active, false if the
|
|
// timer had expired or been stopped.
|
|
Reset(d time.Duration) bool
|
|
// Stop prevents the Timer from firing. It returns true if the call stops the timer, false if the timer has
|
|
// already expired or been stopped.
|
|
Stop() bool
|
|
}
|
|
// RealTimeSource is a timeSource that uses the real wall timeSource time. The zero value is valid.
|
|
RealTimeSource struct{}
|
|
)
|
|
|
|
var _ TimeSource = (*RealTimeSource)(nil)
|
|
|
|
// NewRealTimeSource returns a timeSource that uses the real wall timeSource time.
|
|
func NewRealTimeSource() RealTimeSource {
|
|
return RealTimeSource{}
|
|
}
|
|
|
|
// Now returns the current time, with the location set to UTC.
|
|
func (ts RealTimeSource) Now() time.Time {
|
|
return time.Now().UTC()
|
|
}
|
|
|
|
// Since returns the time elapsed since t
|
|
func (ts RealTimeSource) Since(t time.Time) time.Duration {
|
|
return time.Since(t)
|
|
}
|
|
|
|
// AfterFunc is a pass-through to time.AfterFunc.
|
|
func (ts RealTimeSource) AfterFunc(d time.Duration, f func()) Timer {
|
|
return time.AfterFunc(d, f)
|
|
}
|
|
|
|
// NewTimer is a pass-through to time.NewTimer.
|
|
func (ts RealTimeSource) NewTimer(d time.Duration) (<-chan time.Time, Timer) {
|
|
t := time.NewTimer(d)
|
|
return t.C, t
|
|
}
|