For task details, check the Backend Code Assignment.pdf
file
Time complexity: O(1)
Space complexity: 0(1)
Space estimations:
// 70 bytes * 120_000 records (max cache size before cleanup) = 8MB
internal data class StatsRecord(val t: Long, val amount: Long, val orderCount: Int) {
Tech stack:
- Kotlin 1.3
- Gradle 5.5
- Micronaut Framework 1.2 [https://micronaut.io]
- Junit 5
- Docker
- GraalVM Native Image [https://www.graalvm.org/docs/reference-manual/aot-compilation/]
Build local JAR file: ./gradlew shadowJar
After local build's success, build and run with Docker: docker build .
08:35:41.166 [main] INFO io.micronaut.runtime.Micronaut - Startup completed in 1949ms. Server Running: http://localhost:8080
Set up your IDE to support Micronaut:
- Intellij IDEA: enable annotations and delegate all build tasks to Gradle
- Other IDEs: https://docs.micronaut.io/latest/guide/index.html#ideSetup
- Build, run and continuously rebuild with Gradle:
./gradlew run --continuous
and then after changing a kotlin file this restart message should appear:
08:58:47.667 [main] INFO io.micronaut.runtime.Micronaut - Startup completed in 873ms. Server Running: http://localhost:8080
- Run tests from IDE and check the output:
08:52:43.653 [Test worker] INFO ebay.tx.stats.TxRepoTest - Population time: 296.4 ms Calculation time: 25.41 ms
- Run tests with Gradle
./gradlew clean test