by zetaplusae · 1y ago · 0 comments
It provides an interfaces `Time` with two implementations `SystemTime` for real system clock, and `MutableTime` that can be advanced programmatically. It lets you control time precisely, without relying on mocking frameworks.
What prompted me to build this is that many large projects (like Apache Kafka and Apache Flink) implement their own internal solutions for time control:
- in Kafka: [org.apache.kafka.common.utils.Time](https://github.com/apache/kafka/blob/trunk/clients/src/main/...) - in Flink: [org.apache.flink.util.clock.Clock](https://github.com/apache/flink/blob/master/flink-core/src/m...)
I saw a pattern of duplicated fake clock logic across open source and internal codebases, and decided to make a reusable, standalone alternative.
And, it has been published to Maven Central: - `io.github.predatorray:timestone-api:1.0.0` for API (optional) - `io.github.predatorray:timestone-test:1.0.0` for test
I would love feedback on the design, and to hear how others test time-sensitive code.
No comments yet.