Documentation
¶
Overview ¶
Package clock abstracts time with a real clock and a manually advanced concurrent-safe fake.
Design ¶
Injected time makes certificate validity (NotBefore is always "now", never back-dated), MD5 nonce lifetimes, WNS token expiry, poll backoff and other time-dependent behavior testable without wall-clock delays. Fake coordinates Now, After and manual advancement under a lock. Scheduling and retry policy remain with callers; the package's timer interface is limited to After.
References ¶
- Decision record 0004: https://github.com/deploymenttheory/go-microsoft-dm/blob/main/docs/research/decisions/0004-go-baseline-and-foundation-contracts.md
- Research store, section 7 (back-dated certificate and polling rows): https://github.com/deploymenttheory/go-microsoft-dm/blob/main/docs/research.md
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clock ¶
type Clock interface {
// Now returns the current time.
Now() time.Time
// Since returns the elapsed time since t.
Since(t time.Time) time.Duration
// After waits for the duration to elapse and then sends the current time
// on the returned channel.
After(d time.Duration) <-chan time.Time
}
Clock is the subset of the time package that the library depends on.
type Fake ¶
type Fake struct {
// contains filtered or unexported fields
}
Fake is a manually advanced Clock for tests. It is safe for concurrent use.
func (*Fake) After ¶
After implements Clock. The returned channel fires once Advance or Set moves the clock to or past now+d. A non-positive duration fires immediately.