Skip to content

Commit 33aba2a

Browse files
committed
bump libraries and gradle
1 parent abc165c commit 33aba2a

5 files changed

Lines changed: 23 additions & 26 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
org.gradle.caching=true
22
org.gradle.parallel=true
3-
org.gradle.unsafe.configuration-cache=true
3+
org.gradle.configuration-cache=true
44

55
kotlin.code.style=official
66
kotlin.mpp.stability.nowarn=true

gradle/libs.versions.toml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
[versions]
22

3-
kotlin = "1.7.20"
4-
ksp = "1.7.20-1.0.6"
5-
kotlinter = "3.11.1"
3+
kotlin = "1.8.21"
4+
kotlinter = "3.14.0"
65

7-
kotlinx-coroutines = "1.6.4"
6+
kotlinx-coroutines = "1.7.0-RC"
87
kotlinx-datetime = "0.4.0"
9-
kotlinx-serialization = "1.4.1"
8+
kotlinx-serialization = "1.5.0"
109

11-
okio="3.1.0"
12-
result = "1.1.16"
13-
uuid = "0.5.0"
10+
okio="3.3.0"
11+
result = "1.1.17"
12+
uuid = "0.7.0"
1413

1514
[plugins]
1615

1716
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
1817
kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
1918
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
2019
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
21-
kotlin-symbol-processing = { id = "com.google.devtools.ksp", version.ref = "ksp" }
2220
kotlinter = { id = "org.jmailen.kotlinter", version.ref = "kotlinter" }
2321

2422
[libraries]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/commonMain/kotlin/com/tap/hlc/HybridLogicalClock.kt

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import com.github.michaelbull.result.Result
66
import com.github.michaelbull.result.flatMap
77
import com.github.michaelbull.result.getOr
88
import kotlinx.datetime.Clock
9+
import okio.FileSystem
10+
import okio.Path
911
import kotlin.math.abs
1012
import kotlin.math.max
1113
import kotlin.math.pow
12-
import okio.FileSystem
13-
import okio.Path
1414

1515
/**
1616
* Implementation of a HLC [1][2]
@@ -24,7 +24,7 @@ import okio.Path
2424
data class HybridLogicalClock(
2525
val timestamp: Timestamp = Timestamp.now(Clock.System),
2626
val node: NodeID = NodeID.mint(),
27-
val counter: Int = 0
27+
val counter: Int = 0,
2828
) : Comparable<HybridLogicalClock> {
2929

3030
companion object {
@@ -37,12 +37,14 @@ data class HybridLogicalClock(
3737
fun localTick(
3838
local: HybridLogicalClock,
3939
wallClockTime: Timestamp = Timestamp.now(Clock.System),
40-
maxClockDrift: Int = 1000 * 60
40+
maxClockDrift: Int = 1000 * 60,
4141
): Result<HybridLogicalClock, HLCError> {
4242
return if (wallClockTime.epochMillis > local.timestamp.epochMillis) {
4343
Ok(local.copy(timestamp = wallClockTime))
44-
} else Ok(local.copy(counter = local.counter + 1)).flatMap { clock ->
45-
validate(clock, wallClockTime, maxClockDrift)
44+
} else {
45+
Ok(local.copy(counter = local.counter + 1)).flatMap { clock ->
46+
validate(clock, wallClockTime, maxClockDrift)
47+
}
4648
}
4749
}
4850

@@ -53,7 +55,7 @@ data class HybridLogicalClock(
5355
local: HybridLogicalClock,
5456
remote: HybridLogicalClock,
5557
wallClockTime: Timestamp = Timestamp.now(Clock.System),
56-
maxClockDrift: Int = 1000 * 60
58+
maxClockDrift: Int = 1000 * 60,
5759
): Result<HybridLogicalClock, HLCError> {
5860
return when {
5961
local.node.identifier == remote.node.identifier -> {
@@ -119,7 +121,7 @@ data class HybridLogicalClock(
119121
* val directory = "/Users/alice".toPath()
120122
* HybridLogicalClock.store(hlc, path)
121123
*/
122-
fun store(hlc: HybridLogicalClock, directory: Path, fileSystem: FileSystem = FileSystem.SYSTEM, fileName : String = CLOCK_FILE) {
124+
fun store(hlc: HybridLogicalClock, directory: Path, fileSystem: FileSystem = FileSystem.SYSTEM, fileName: String = CLOCK_FILE) {
123125
fileSystem.createDirectories(directory)
124126
val filepath = directory / fileName
125127
fileSystem.write(filepath) {
@@ -136,9 +138,9 @@ data class HybridLogicalClock(
136138
* val directory = "/Users/alice".toPath()
137139
* val nullableClock = HybridLogicalClock.load(path)
138140
*/
139-
fun load(directory: Path, fileSystem: FileSystem = FileSystem.SYSTEM, fileName: String = CLOCK_FILE) : HybridLogicalClock? {
141+
fun load(directory: Path, fileSystem: FileSystem = FileSystem.SYSTEM, fileName: String = CLOCK_FILE): HybridLogicalClock? {
140142
val filepath = directory / fileName
141-
if(!fileSystem.exists(filepath)) {
143+
if (!fileSystem.exists(filepath)) {
142144
return null
143145
}
144146
val encoded = fileSystem.read(filepath) { readUtf8() }

src/commonTest/kotlin/com/tap/hlc/HLCPersistTest.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
package com.tap.hlc
22

33
import com.benasher44.uuid.uuid4
4+
import okio.Path.Companion.toPath
5+
import okio.fakefilesystem.FakeFileSystem
46
import kotlin.test.Test
57
import kotlin.test.assertEquals
68
import kotlin.test.assertNotNull
7-
import okio.Path.Companion.toPath
8-
import okio.fakefilesystem.FakeFileSystem
99

1010
class HLCPersistTest {
1111

1212
@Test
1313
fun `can store the hlc into a file at a given path`() {
14-
1514
val fileSystem = FakeFileSystem()
1615

1716
val epochMillis = 943920000000L
@@ -35,7 +34,6 @@ class HLCPersistTest {
3534

3635
@Test
3736
fun `can load a hlc from a given path`() {
38-
3937
val fileSystem = FakeFileSystem()
4038
val path = "/Users/alice".toPath()
4139
fileSystem.createDirectories(path)
@@ -62,7 +60,6 @@ class HLCPersistTest {
6260

6361
@Test
6462
fun `can store and load a hlc to and from a given path`() {
65-
6663
val fileSystem = FakeFileSystem()
6764
val path = "/Users/alice".toPath()
6865
fileSystem.createDirectories(path)

0 commit comments

Comments
 (0)