Dropwizard Discoverable configuration factories that do not require, but can be used with JFConfig
All ClockFactory implementations will return a Clock with the time zone set by the zoneId configuration property. When the zoneId property is null the clock will use the system default time zone.
clockFactory:
type: system
clockFactory:
type: system
zoneId: UTC
The FixableClockFactory is used to easily switch between a "normal" system clock and a fixed clock
When environemt variable FIX_TIME is not set, the clockFactory will return a normal system clock in the Paris time zone Setting FIX_TIME to 2018-02-08 08:05 will fix the clock to that local time (2018-02-08 07:05 UTC)
clockFactory:
type: fixable
instant: ${FIX_TIME:-}
format: yyyy-MM-dd HH:mm
zoneId: Europe/Paris
The configuration above is using JFConfig which in turn uses the apache StrSubstitutor to replace environment variables.
The
Completely flexible configuration
clockFactory:
type: fixable
instant: ${FIX_TIME:-}
format: ${FIX_TIME_FORMAT:-yyyy-MM-dd HH:mm}
zoneId: ${FIX_TIME_ZONE:-}
Return a system clock offset by the configured duration.
When an instant is configured (as above for the fixable factory) the offset is calculated as the difference between the instant and the system clock. This means that the clock returned will initially be set to the configured instant and then keep ticking.
When instant is configured the duration is ignored.
clockFactory:
type: system-offset
offset: P2D
clockFactory:
type: system-offset
instant: 2018-06-30 03:55
format: yyyy-MM-dd HH:mm
zoneId: Europe/London
Use environment variables to choose between a system clock (OFFSET_DURATION and INITIAL_TIME both unset or empty), a clock offset by a duration, or a clock which is initially set to a specific instant in time
clockFactory:
type: system-offset
offset: ${OFFSET_DURATION:-}
instant: ${INITIAL_TIME:-}
format: ${INITIAL_TIME_FORMAT:-yyyy-MM-dd HH:mm}
zoneId: ${TIME_ZONE:-}
The MutableClock returned from this factory delegates all calls to an underlying clock which can be swapped out using methods on the MutableClock.
The initial delegate clock is set by providing a ClockFactory and can be restored by calling reset() on the MutableClock.
clockFactory:
type: mutable
initialClockFactory:
type: system
zoneId: UTC