Documentation
¶
Overview ¶
Package clock abstracts time with a real clock and a manually advanced concurrent-safe fake.
Design ¶
Injected time makes certificate validity, token expiry, queue 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 0006: https://github.com/deploymenttheory/go-apple-dm/blob/main/docs/research/decisions/0006-mdm-signature-verification.md (signing-time skew)
- Decision record 0019: https://github.com/deploymenttheory/go-apple-dm/blob/main/docs/research/decisions/0019-canonical-json-and-ddm-tokens.md (token timestamps)
- Apple: https://developer.apple.com/documentation/devicemanagement/handling-notnow-status-responses
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.