Skip to content

Commit

Permalink
bump dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
scrayos committed Nov 3, 2024
1 parent 5d34246 commit f062582
Show file tree
Hide file tree
Showing 17 changed files with 314 additions and 333 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ After your instance is up and running, you have to add Xenos Client for Kotlin t
```kotlin
dependencies {
// make sure to specify the latest version
api("net.scrayos", "xenos-client", "0.1.0")
api("net.scrayos", "xenos-client", "0.8.0")

// choose your own gRPC runtime or use an existing one
runtimeOnly("io.grpc", "grpc-netty", "1.63.0")
runtimeOnly("io.grpc", "grpc-netty", "1.68.1")
}
```

Expand Down
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ dependencies {
// specify test dependencies
testImplementation(libs.kotlin.test)
testImplementation(libs.bundles.kotest)
testImplementation(libs.mockk)
testImplementation(libs.bundles.log4j)
testRuntimeOnly(libs.grpc.netty)
}
Expand Down
22 changes: 10 additions & 12 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
[versions]
kotlin = "2.0.0"
kotlin = "2.0.21"
dokka = "1.9.20"
ktlint = "1.2.1"
junit = "5.10.2"
kotest-core = "5.9.0"
ktlint = "1.4.0"
junit = "5.11.3"
kotest-core = "5.9.1"
kotest-testcontainers = "2.0.2"
protobuf = "3.25.3"
protoc-java = "1.64.0"
protobuf = "4.28.3"
protoc-java = "1.68.1"
protoc-kotlin = "1.4.1"
kotlin-coroutines = "1.8.1"
slf4j = "2.0.13"
log4j = "2.23.1"
mockk = "1.13.11"
kotlin-coroutines = "1.9.0"
slf4j = "2.0.16"
log4j = "2.24.1"

[libraries]
protobuf-kotlin = { group = "com.google.protobuf", name = "protobuf-kotlin", version.ref = "protobuf" }
Expand All @@ -28,7 +27,6 @@ log4j-slf4j = { group = "org.apache.logging.log4j", name = "log4j-slf4j-impl", v
protoc-core = { group = "com.google.protobuf", name = "protoc", version.ref = "protobuf" }
protoc-genJava = { group = "io.grpc", name = "protoc-gen-grpc-java", version.ref = "protoc-java" }
protoc-genKotlin = { group = "io.grpc", name = "protoc-gen-grpc-kotlin", version.ref = "protoc-kotlin" }
mockk = { group = "io.mockk", name = "mockk", version.ref = "mockk" }

[bundles]
kotest = ["kotest-runner", "kotest-testcontainers"]
Expand All @@ -44,4 +42,4 @@ kover = { id = "org.jetbrains.kotlinx.kover", version = "0.8.0" }
protobuf = { id = "com.google.protobuf", version = "0.9.4" }
sonarqube = { id = "org.sonarqube", version = "5.0.0.4638" }
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version = "12.1.1" }
mavenPublish = { id = "com.vanniktech.maven.publish", version = "0.28.0" }
mavenPublish = { id = "com.vanniktech.maven.publish", version = "0.29.0" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
122 changes: 56 additions & 66 deletions src/main/kotlin/net/scrayos/xenos/client/GrpcXenosClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,17 @@ class GrpcXenosClient(
/** The coroutine-based stub for the communication with the gRPC interface of Xenos. */
private val stub: ProfileGrpcKt.ProfileCoroutineStub = ProfileGrpcKt.ProfileCoroutineStub(channel)

override suspend fun getUuid(name: String): UuidInfo? {
return try {
stub.getUuid(
uuidRequest {
username = name
},
).toResult()
} catch (ex: StatusException) {
when (ex.status.code) {
UNAVAILABLE -> throw IllegalStateException("Xenos could not fetch the requested uuid")
NOT_FOUND -> null
else -> throw ex
}
override suspend fun getUuid(name: String): UuidInfo? = try {
stub.getUuid(
uuidRequest {
username = name
},
).toResult()
} catch (ex: StatusException) {
when (ex.status.code) {
UNAVAILABLE -> throw IllegalStateException("Xenos could not fetch the requested uuid")
NOT_FOUND -> null
else -> throw ex
}
}

Expand All @@ -79,68 +77,60 @@ class GrpcXenosClient(
},
).toResult()

override suspend fun getProfile(userId: UUID): ProfileInfo? {
return try {
stub.getProfile(
profileRequest {
uuid = userId.toString()
},
).toResult()
} catch (ex: StatusException) {
when (ex.status.code) {
UNAVAILABLE -> throw IllegalStateException("Xenos could not fetch the requested profile")
NOT_FOUND -> null
else -> throw ex
}
override suspend fun getProfile(userId: UUID): ProfileInfo? = try {
stub.getProfile(
profileRequest {
uuid = userId.toString()
},
).toResult()
} catch (ex: StatusException) {
when (ex.status.code) {
UNAVAILABLE -> throw IllegalStateException("Xenos could not fetch the requested profile")
NOT_FOUND -> null
else -> throw ex
}
}

override suspend fun getSkin(userId: UUID): SkinInfo? {
return try {
stub.getSkin(
skinRequest {
uuid = userId.toString()
},
).toResult()
} catch (ex: StatusException) {
when (ex.status.code) {
UNAVAILABLE -> throw IllegalStateException("Xenos could not fetch the requested skin")
NOT_FOUND -> null
else -> throw ex
}
override suspend fun getSkin(userId: UUID): SkinInfo? = try {
stub.getSkin(
skinRequest {
uuid = userId.toString()
},
).toResult()
} catch (ex: StatusException) {
when (ex.status.code) {
UNAVAILABLE -> throw IllegalStateException("Xenos could not fetch the requested skin")
NOT_FOUND -> null
else -> throw ex
}
}

override suspend fun getCape(userId: UUID): CapeInfo? {
return try {
stub.getCape(
capeRequest {
uuid = userId.toString()
},
).toResult()
} catch (ex: StatusException) {
when (ex.status.code) {
UNAVAILABLE -> throw IllegalStateException("Xenos could not fetch the requested cape")
NOT_FOUND -> null
else -> throw ex
}
override suspend fun getCape(userId: UUID): CapeInfo? = try {
stub.getCape(
capeRequest {
uuid = userId.toString()
},
).toResult()
} catch (ex: StatusException) {
when (ex.status.code) {
UNAVAILABLE -> throw IllegalStateException("Xenos could not fetch the requested cape")
NOT_FOUND -> null
else -> throw ex
}
}

override suspend fun getHead(userId: UUID, includeOverlay: Boolean): HeadInfo? {
return try {
stub.getHead(
headRequest {
uuid = userId.toString()
overlay = includeOverlay
},
).toResult()
} catch (ex: StatusException) {
when (ex.status.code) {
UNAVAILABLE -> throw IllegalStateException("Xenos could not fetch the requested head")
NOT_FOUND -> null
else -> throw ex
}
override suspend fun getHead(userId: UUID, includeOverlay: Boolean): HeadInfo? = try {
stub.getHead(
headRequest {
uuid = userId.toString()
overlay = includeOverlay
},
).toResult()
} catch (ex: StatusException) {
when (ex.status.code) {
UNAVAILABLE -> throw IllegalStateException("Xenos could not fetch the requested head")
NOT_FOUND -> null
else -> throw ex
}
}

Expand Down
10 changes: 4 additions & 6 deletions src/main/kotlin/net/scrayos/xenos/client/data/CapeInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ data class CapeInfo(
* information that is related to the gRPC origin and is therefore independent of the client implementation, that was
* used to retrieve the data from Xenos.
*/
internal fun CapeResponse.toResult(): CapeInfo {
return CapeInfo(
bytes.toImage(),
Instant.ofEpochSecond(timestamp),
)
}
internal fun CapeResponse.toResult(): CapeInfo = CapeInfo(
bytes.toImage(),
Instant.ofEpochSecond(timestamp),
)
12 changes: 5 additions & 7 deletions src/main/kotlin/net/scrayos/xenos/client/data/HeadInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ data class HeadInfo(
* information that is related to the gRPC origin and is therefore independent of the client implementation, that was
* used to retrieve the data from Xenos.
*/
internal fun HeadResponse.toResult(): HeadInfo {
return HeadInfo(
bytes.toImage(),
Instant.ofEpochSecond(timestamp),
default,
)
}
internal fun HeadResponse.toResult(): HeadInfo = HeadInfo(
bytes.toImage(),
Instant.ofEpochSecond(timestamp),
default,
)
28 changes: 13 additions & 15 deletions src/main/kotlin/net/scrayos/xenos/client/data/ProfileInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,16 @@ data class ProfileInfo(
* information that is related to the gRPC origin and is therefore independent of the client implementation, that was
* used to retrieve the data from Xenos.
*/
internal fun ProfileResponse.toResult(): ProfileInfo {
return ProfileInfo(
UUID.fromString(uuid),
name,
propertiesList.map {
ProfileInfo.Property(
it.name,
it.value,
if (it.hasSignature()) it.signature else null,
)
}.toSet(),
profileActionsList.toSet(),
Instant.ofEpochSecond(timestamp),
)
}
internal fun ProfileResponse.toResult(): ProfileInfo = ProfileInfo(
UUID.fromString(uuid),
name,
propertiesList.map {
ProfileInfo.Property(
it.name,
it.value,
if (it.hasSignature()) it.signature else null,
)
}.toSet(),
profileActionsList.toSet(),
Instant.ofEpochSecond(timestamp),
)
12 changes: 5 additions & 7 deletions src/main/kotlin/net/scrayos/xenos/client/data/SkinInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ data class SkinInfo(
* information that is related to the gRPC origin and is therefore independent of the client implementation, that was
* used to retrieve the data from Xenos.
*/
internal fun SkinResponse.toResult(): SkinInfo {
return SkinInfo(
bytes.toImage(),
Instant.ofEpochSecond(timestamp),
default,
)
}
internal fun SkinResponse.toResult(): SkinInfo = SkinInfo(
bytes.toImage(),
Instant.ofEpochSecond(timestamp),
default,
)
24 changes: 10 additions & 14 deletions src/main/kotlin/net/scrayos/xenos/client/data/UuidInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,20 @@ data class UuidInfo(
* information that is related to the gRPC origin and is therefore independent of the client implementation, that was
* used to retrieve the data from Xenos.
*/
internal fun UuidResponse.toResult(): UuidInfo {
return UuidInfo(
UUID.fromString(uuid),
username,
Instant.ofEpochSecond(timestamp),
)
}
internal fun UuidResponse.toResult(): UuidInfo = UuidInfo(
UUID.fromString(uuid),
username,
Instant.ofEpochSecond(timestamp),
)

/**
* Converts the raw response from gRPC into a more user-friendly data class, that encapsulates the contained data in an
* easy-to-use format. No information is dropped or lost through the conversion. The wrapped response drops all
* information that is related to the gRPC origin and is therefore independent of the client implementation, that was
* used to retrieve the data from Xenos.
*/
internal fun UuidsResponse.toResult(): Map<String, UuidInfo> {
return resolvedMap
.mapValues {
it.value.toResult()
}
.toMap()
}
internal fun UuidsResponse.toResult(): Map<String, UuidInfo> = resolvedMap
.mapValues {
it.value.toResult()
}
.toMap()
18 changes: 9 additions & 9 deletions src/test/kotlin/net/scrayos/xenos/client/GrpcXenosClientTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import net.scrayos.xenos.client.utility.toImage
import org.testcontainers.containers.GenericContainer
import java.util.UUID

class GrpcXenosClientTest : ShouldSpec(
{
val container = GenericContainer<Nothing>("ghcr.io/scrayosnet/xenos:v0.3.0-static").apply {
class GrpcXenosClientTest : ShouldSpec() {
init {
val container = GenericContainer<Nothing>("ghcr.io/scrayosnet/xenos:0.6.1-testing").apply {
withExposedPorts(50051)
}
val xenos = install(ContainerExtension(container))
Expand Down Expand Up @@ -161,10 +161,10 @@ class GrpcXenosClientTest : ShouldSpec(
result.properties shouldContainExactly setOf(
ProfileInfo.Property(
"textures",
"eyJ0aW1lc3RhbXAiOjAsInByb2ZpbGVJZCI6IjljMDllZWY0LWY2OGQtNDM4Ny05NzUxLTcyYmJmZjUzZDVhM" +
"CIsInByb2ZpbGVOYW1lIjoiU2NyYXlvcyIsInNpZ25hdHVyZVJlcXVpcmVkIjpudWxsLCJ0ZXh0dXJlcyI6eyJT" +
"S0lOIjp7InVybCI6InNraW5fOWMwOWVlZjQtZjY4ZC00Mzg3LTk3NTEtNzJiYmZmNTNkNWEwIiwibWV0YWRhdGE" +
"iOm51bGx9LCJDQVBFIjpudWxsfX0=",
"eyJ0aW1lc3RhbXAiOjAsInByb2ZpbGVJZCI6IjljMDllZWY0LWY2OGQtNDM4Ny05NzUxLTcyYmJmZjUzZD" +
"VhMCIsInByb2ZpbGVOYW1lIjoiU2NyYXlvcyIsInNpZ25hdHVyZVJlcXVpcmVkIjpudWxsLCJ0ZXh0dXJlcy" +
"I6eyJTS0lOIjp7InVybCI6InNraW5fOWMwOWVlZjQtZjY4ZC00Mzg3LTk3NTEtNzJiYmZmNTNkNWEwIiwibW" +
"V0YWRhdGEiOm51bGx9LCJDQVBFIjpudWxsfX0=",
null,
),
)
Expand Down Expand Up @@ -274,5 +274,5 @@ class GrpcXenosClientTest : ShouldSpec(
Thread.interrupted().shouldBeTrue()
}
}
},
)
}
}
Loading

0 comments on commit f062582

Please sign in to comment.