Skip to content

Commit b2d57d9

Browse files
Service protocol v4 (#447)
1 parent 91296a3 commit b2d57d9

File tree

332 files changed

+13824
-12353
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

332 files changed

+13824
-12353
lines changed

buf.lock

Lines changed: 0 additions & 2 deletions
This file was deleted.

buf.yaml

Lines changed: 0 additions & 8 deletions
This file was deleted.

build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import com.github.jk1.license.render.ReportRenderer
2+
13
plugins {
24
alias(libs.plugins.dependency.license.report)
35
alias(libs.plugins.nexus.publish)
@@ -45,7 +47,7 @@ allprojects {
4547
tasks.named("check") { dependsOn("checkLicense") }
4648

4749
licenseReport {
48-
renderers = arrayOf(com.github.jk1.license.render.CsvReportRenderer())
50+
renderers = arrayOf<ReportRenderer>(com.github.jk1.license.render.CsvReportRenderer())
4951

5052
excludeBoms = true
5153

buildSrc/src/main/kotlin/library-publishing-conventions.gradle.kts

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,68 @@ project.afterEvaluate {
77
publishing {
88
publications {
99
create<MavenPublication>("maven") {
10+
afterEvaluate {
11+
val shadowJar = tasks.findByName("shadowJar")
12+
if (shadowJar == null) {
13+
from(components["java"])
14+
}
15+
else {
16+
apply(plugin = "com.gradleup.shadow")
17+
18+
from(components["shadow"])
19+
artifact(tasks["sourcesJar"]!!)
20+
artifact(tasks["javadocJar"]!!)
21+
22+
afterEvaluate {
23+
// Fix for avoiding inclusion of runtime dependencies marked as 'shadow' in MANIFEST Class-Path.
24+
// https://github.com/johnrengelman/shadow/issues/324
25+
pom.withXml {
26+
val rootNode = asElement()
27+
val doc = rootNode.ownerDocument
28+
29+
val dependenciesNode =
30+
if (rootNode.getElementsByTagName("dependencies").length != 0) {
31+
rootNode.getElementsByTagName("dependencies").item(0)
32+
} else {
33+
rootNode.appendChild(
34+
doc.createElement("dependencies")
35+
)
36+
}
37+
38+
project.configurations["shade"].allDependencies.forEach { dep ->
39+
dependenciesNode.appendChild(
40+
doc.createElement("dependency").apply {
41+
appendChild(
42+
doc.createElement("groupId").apply {
43+
textContent = dep.group
44+
}
45+
)
46+
appendChild(
47+
doc.createElement("artifactId").apply {
48+
textContent = dep.name
49+
}
50+
)
51+
appendChild(
52+
doc.createElement("version").apply {
53+
textContent = dep.version
54+
}
55+
)
56+
appendChild(
57+
doc.createElement("scope").apply {
58+
textContent = "runtime"
59+
}
60+
)
61+
}
62+
)
63+
}
64+
}
65+
}
66+
}
67+
}
68+
1069
groupId = "dev.restate"
1170
artifactId = project.name
1271

13-
from(components["java"])
14-
1572
pom {
1673
name = "Restate SDK :: ${project.name}"
1774
description = project.description!!

buildSrc/src/main/kotlin/test-jar-conventions.gradle.kts

Lines changed: 0 additions & 9 deletions
This file was deleted.

client-kotlin/build.gradle.kts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
plugins {
2+
`kotlin-conventions`
3+
`library-publishing-conventions`
4+
}
5+
6+
description = "Restate Client to interact with services from within other Kotlin applications"
7+
8+
dependencies {
9+
api(project(":client"))
10+
implementation(libs.kotlinx.coroutines.core)
11+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// Copyright (c) 2023 - Restate Software, Inc., Restate GmbH
2+
//
3+
// This file is part of the Restate Java SDK,
4+
// which is released under the MIT license.
5+
//
6+
// You can find a copy of the license in file LICENSE in the root
7+
// directory of this repository or package, or at
8+
// https://github.com/restatedev/sdk-java/blob/main/LICENSE
9+
package dev.restate.client.kotlin
10+
11+
import dev.restate.client.Client
12+
import dev.restate.client.ClientRequestOptions
13+
import dev.restate.client.ClientResponse
14+
import dev.restate.client.SendResponse
15+
import dev.restate.common.Output
16+
import dev.restate.common.Request
17+
import dev.restate.serde.Serde
18+
import kotlinx.coroutines.future.await
19+
20+
// Extension methods for the Client
21+
22+
fun clientRequestOptions(init: ClientRequestOptions.Builder.() -> Unit): ClientRequestOptions {
23+
val builder = ClientRequestOptions.builder()
24+
builder.init()
25+
return builder.build()
26+
}
27+
28+
suspend fun <Req, Res> Client.callSuspend(request: Request<Req, Res>): ClientResponse<Res> {
29+
return this.callAsync(request).await()
30+
}
31+
32+
suspend fun <Req, Res> Client.callSuspend(
33+
requestBuilder: Request.Builder<Req, Res>
34+
): ClientResponse<Res> {
35+
return this.callAsync(requestBuilder).await()
36+
}
37+
38+
suspend fun <Req, Res> Client.sendSuspend(
39+
request: Request<Req, Res>
40+
): ClientResponse<SendResponse<Res>> {
41+
return this.sendAsync(request).await()
42+
}
43+
44+
suspend fun <Req, Res> Client.sendSuspend(
45+
request: Request.Builder<Req, Res>
46+
): ClientResponse<SendResponse<Res>> {
47+
return this.sendSuspend(request.build())
48+
}
49+
50+
suspend fun <T : Any> Client.AwakeableHandle.resolveSuspend(
51+
serde: Serde<T>,
52+
payload: T,
53+
options: ClientRequestOptions = ClientRequestOptions.DEFAULT
54+
): ClientResponse<Void> {
55+
return this.resolveAsync(serde, payload, options).await()
56+
}
57+
58+
suspend fun Client.AwakeableHandle.rejectSuspend(
59+
reason: String,
60+
options: ClientRequestOptions = ClientRequestOptions.DEFAULT
61+
): ClientResponse<Void> {
62+
return this.rejectAsync(reason, options).await()
63+
}
64+
65+
suspend fun <T> Client.InvocationHandle<T>.attachSuspend(
66+
options: ClientRequestOptions = ClientRequestOptions.DEFAULT
67+
): ClientResponse<T> {
68+
return this.attachAsync(options).await()
69+
}
70+
71+
suspend fun <T : Any?> Client.InvocationHandle<T>.getOutputSuspend(
72+
options: ClientRequestOptions = ClientRequestOptions.DEFAULT
73+
): ClientResponse<Output<T>> {
74+
return this.getOutputAsync(options).await()
75+
}
76+
77+
suspend fun <T> Client.IdempotentInvocationHandle<T>.attachSuspend(
78+
options: ClientRequestOptions = ClientRequestOptions.DEFAULT
79+
): ClientResponse<T> {
80+
return this.attachAsync(options).await()
81+
}
82+
83+
suspend fun <T> Client.IdempotentInvocationHandle<T>.getOutputSuspend(
84+
options: ClientRequestOptions = ClientRequestOptions.DEFAULT
85+
): ClientResponse<Output<T>> {
86+
return this.getOutputAsync(options).await()
87+
}
88+
89+
suspend fun <T> Client.WorkflowHandle<T>.attachSuspend(
90+
options: ClientRequestOptions = ClientRequestOptions.DEFAULT
91+
): ClientResponse<T> {
92+
return this.attachAsync(options).await()
93+
}
94+
95+
suspend fun <T> Client.WorkflowHandle<T>.getOutputSuspend(
96+
options: ClientRequestOptions = ClientRequestOptions.DEFAULT
97+
): ClientResponse<Output<T>> {
98+
return this.getOutputAsync(options).await()
99+
}

client/build.gradle.kts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
plugins {
2+
`java-library`
3+
`java-conventions`
4+
`kotlin-conventions`
5+
`library-publishing-conventions`
6+
}
7+
8+
description = "Restate Client to interact with services from within other Java applications"
9+
10+
dependencies {
11+
compileOnly(libs.jspecify)
12+
13+
api(project(":common"))
14+
15+
implementation(libs.jackson.core)
16+
implementation(libs.log4j.api)
17+
18+
testImplementation(libs.junit.jupiter)
19+
testImplementation(libs.assertj)
20+
}

0 commit comments

Comments
 (0)