Skip to content

xtr_clock.bundle

The xtr-dependency-injection bundle for xtr-clock.

ClockBundle

ClockBundle()

Bases: Bundle[ClockConfig]

Provides a :class:Clock and keeps :meth:Clock.get in sync with it.

Prepare for the boot-time :meth:Clock.install installation.

load_extension

load_extension(config: ClockConfig, services: ServiceConfigurator, builder: ContainerBuilder) -> None

Register a :class:Clock factory and alias :class:ClockInterface onto it.

boot async

boot() -> None

Install the container-built clock as :meth:Clock.get for the lifetime of the kernel.

shutdown async

shutdown() -> None

Restore the clock that was in force when :meth:boot ran.

ClockConfig dataclass

ClockConfig(timezone: str | None = _UTC)

How the clock bundle builds its :class:~xtr_clock.clock.Clock.

The clock reports in UTC unless told otherwise, so an application reads the same instant the same way on a laptop, in a container and in CI, whatever each machine's own zone is set to.

Attributes:

  • timezone (str | None) –

    The zone :meth:~xtr_clock.clock.Clock.now reports in: "UTC" unless set, any zone name the system knows, or None to follow the machine's own zone.