clock

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package clock holds the two clocks of Muster, which code takes by injection instead of calling time.Now() or SQL now() (ADR-0006). The business clock is the time of the domain: domain timestamps, timers, windows, retention, sessions, the alive mark and downtime; in development mode it runs ahead of the system time by the offset of the development clock. The real clock is always the system time, for what must agree with the world outside the database or with other processes: TOTP steps, ID-token times, webhook signatures, row and Leader leases, the clock skew check and replica records. Each has a manual implementation that drives tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func System

func System() (Clocks, *Business)

System returns the clocks of a running process: the real clock and a business clock without an offset, which the development clock can move.

Types

type Business

type Business struct {
	// contains filtered or unexported fields
}

Business is the system time plus an offset that only the development clock moves; its zero value has no offset.

func (*Business) Now

func (b *Business) Now() time.Time

func (*Business) Offset

func (b *Business) Offset() time.Duration

Offset is how far the business clock runs ahead of the system time.

func (*Business) SetOffset

func (b *Business) SetOffset(d time.Duration)

SetOffset sets how far the business clock runs ahead of the system time.

type Clock

type Clock interface {
	Now() time.Time
}

Clock tells the time.

type Clocks

type Clocks struct {
	Business Clock
	Real     Clock
}

Clocks are the two clocks of a process.

type Manual

type Manual struct {
	// contains filtered or unexported fields
}

Manual is a clock that moves only when told to, for tests.

func NewManual

func NewManual(t time.Time) *Manual

NewManual returns a manual clock that reads t.

func (*Manual) Advance

func (m *Manual) Advance(d time.Duration)

Advance moves the clock forward by d.

func (*Manual) Now

func (m *Manual) Now() time.Time

func (*Manual) Set

func (m *Manual) Set(t time.Time)

Set moves the clock to t.

type Real

type Real struct{}

Real is the system time.

func (Real) Now

func (Real) Now() time.Time

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL