<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <!-- This module was also published with a richer model, Gradle metadata,  -->
  <!-- which should be used instead. Do not delete the following line which  -->
  <!-- is to indicate to Gradle or any Gradle module metadata file consumer  -->
  <!-- that they should prefer consuming it instead. -->
  <!-- do_not_remove: published-with-gradle-metadata -->
  <modelVersion>4.0.0</modelVersion>
  <groupId>se.wollan</groupId>
  <artifactId>time</artifactId>
  <version>0.1.1</version>
  <name>se.wollan:time</name>
  <description># Time

To be able to timestamp events in a distributed system, we use a [hybrid logical clock](https://cse.buffalo.edu/tech-reports/2014-04.pdf).
For our purposes, with relatively few events and the assumption that the physical clock will progress faster than the logical in the long run, the naive HLC impl will suffice and the timestamp value will in pratice be bounded.

## Install

``` kotlin
implementation("se.wollan:time:&lt;version&gt;")
```

[Stable versions](https://central.sonatype.com/artifact/se.wollan/time/).

[Snapshot versions](https://oss.sonatype.org/content/repositories/snapshots/se/wollan/time/).

``` kotlin
repositories {
    mavenCentral()
    maven("https://oss.sonatype.org/content/repositories/snapshots/")
}
```

## Usage

``` kotlin
// 1. Bootstrap application
val timeModule = TimeModule({ coroutineScope }, { database })
val migrator = timeModule.resolveDatabaseMigrator()
val hybridLogicalClockSynchronizer = timeModule.resolveHybridLogicalClockSynchronizer()
val hybridLogicalClock = timeModule.resolveHybridLogicalClock()
val physicalClock = timeModule.resolvePhysicalClock()

// 2. Run migration
migrator.migrate()

// 3. Use clocks
val hlcTimestamp = hybridLogicalClock.tick()
```</description>
  <url>https://bitbucket.org/wollan/time</url>
  <licenses>
    <license>
      <name>CC BY-NC-ND 4.0</name>
      <url>https://creativecommons.org/licenses/by-nc-nd/4.0/</url>
    </license>
  </licenses>
  <developers>
    <developer>
      <id>wollan</id>
      <name>wollan</name>
      <email>wollan@wollan.se</email>
    </developer>
  </developers>
  <scm>
    <connection>scm:git:git://bitbucket.org/wollan/time.git</connection>
    <developerConnection>scm:git:ssh://bitbucket.org/wollan/time.git</developerConnection>
    <url>http://bitbucket.org/wollan/time/src</url>
  </scm>
  <dependencies>
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-stdlib-jdk8</artifactId>
      <version>1.8.10</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.jetbrains.kotlinx</groupId>
      <artifactId>kotlinx-coroutines-core-jvm</artifactId>
      <version>1.7.3</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.jetbrains.kotlinx</groupId>
      <artifactId>kotlinx-serialization-core-jvm</artifactId>
      <version>1.6.2</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>se.wollan</groupId>
      <artifactId>data-scope</artifactId>
      <version>1.0.0-rc10</version>
      <scope>runtime</scope>
    </dependency>
  </dependencies>
</project>
