Skip to content

Commit

Permalink
Service protocol v4 (#447)
Browse files Browse the repository at this point in the history
  • Loading branch information
slinkydeveloper authored Feb 20, 2025
1 parent 91296a3 commit b2d57d9
Show file tree
Hide file tree
Showing 332 changed files with 13,824 additions and 12,353 deletions.
2 changes: 0 additions & 2 deletions buf.lock

This file was deleted.

8 changes: 0 additions & 8 deletions buf.yaml

This file was deleted.

4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.github.jk1.license.render.ReportRenderer

plugins {
alias(libs.plugins.dependency.license.report)
alias(libs.plugins.nexus.publish)
Expand Down Expand Up @@ -45,7 +47,7 @@ allprojects {
tasks.named("check") { dependsOn("checkLicense") }

licenseReport {
renderers = arrayOf(com.github.jk1.license.render.CsvReportRenderer())
renderers = arrayOf<ReportRenderer>(com.github.jk1.license.render.CsvReportRenderer())

excludeBoms = true

Expand Down
61 changes: 59 additions & 2 deletions buildSrc/src/main/kotlin/library-publishing-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,68 @@ project.afterEvaluate {
publishing {
publications {
create<MavenPublication>("maven") {
afterEvaluate {
val shadowJar = tasks.findByName("shadowJar")
if (shadowJar == null) {
from(components["java"])
}
else {
apply(plugin = "com.gradleup.shadow")

from(components["shadow"])
artifact(tasks["sourcesJar"]!!)
artifact(tasks["javadocJar"]!!)

afterEvaluate {
// Fix for avoiding inclusion of runtime dependencies marked as 'shadow' in MANIFEST Class-Path.
// https://github.com/johnrengelman/shadow/issues/324
pom.withXml {
val rootNode = asElement()
val doc = rootNode.ownerDocument

val dependenciesNode =
if (rootNode.getElementsByTagName("dependencies").length != 0) {
rootNode.getElementsByTagName("dependencies").item(0)
} else {
rootNode.appendChild(
doc.createElement("dependencies")
)
}

project.configurations["shade"].allDependencies.forEach { dep ->
dependenciesNode.appendChild(
doc.createElement("dependency").apply {
appendChild(
doc.createElement("groupId").apply {
textContent = dep.group
}
)
appendChild(
doc.createElement("artifactId").apply {
textContent = dep.name
}
)
appendChild(
doc.createElement("version").apply {
textContent = dep.version
}
)
appendChild(
doc.createElement("scope").apply {
textContent = "runtime"
}
)
}
)
}
}
}
}
}

groupId = "dev.restate"
artifactId = project.name

from(components["java"])

pom {
name = "Restate SDK :: ${project.name}"
description = project.description!!
Expand Down
9 changes: 0 additions & 9 deletions buildSrc/src/main/kotlin/test-jar-conventions.gradle.kts

This file was deleted.

11 changes: 11 additions & 0 deletions client-kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
plugins {
`kotlin-conventions`
`library-publishing-conventions`
}

description = "Restate Client to interact with services from within other Kotlin applications"

dependencies {
api(project(":client"))
implementation(libs.kotlinx.coroutines.core)
}
99 changes: 99 additions & 0 deletions client-kotlin/src/main/kotlin/dev/restate/client/kotlin/ingress.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// Copyright (c) 2023 - Restate Software, Inc., Restate GmbH
//
// This file is part of the Restate Java SDK,
// which is released under the MIT license.
//
// You can find a copy of the license in file LICENSE in the root
// directory of this repository or package, or at
// https://github.com/restatedev/sdk-java/blob/main/LICENSE
package dev.restate.client.kotlin

import dev.restate.client.Client
import dev.restate.client.ClientRequestOptions
import dev.restate.client.ClientResponse
import dev.restate.client.SendResponse
import dev.restate.common.Output
import dev.restate.common.Request
import dev.restate.serde.Serde
import kotlinx.coroutines.future.await

// Extension methods for the Client

fun clientRequestOptions(init: ClientRequestOptions.Builder.() -> Unit): ClientRequestOptions {
val builder = ClientRequestOptions.builder()
builder.init()
return builder.build()
}

suspend fun <Req, Res> Client.callSuspend(request: Request<Req, Res>): ClientResponse<Res> {
return this.callAsync(request).await()
}

suspend fun <Req, Res> Client.callSuspend(
requestBuilder: Request.Builder<Req, Res>
): ClientResponse<Res> {
return this.callAsync(requestBuilder).await()
}

suspend fun <Req, Res> Client.sendSuspend(
request: Request<Req, Res>
): ClientResponse<SendResponse<Res>> {
return this.sendAsync(request).await()
}

suspend fun <Req, Res> Client.sendSuspend(
request: Request.Builder<Req, Res>
): ClientResponse<SendResponse<Res>> {
return this.sendSuspend(request.build())
}

suspend fun <T : Any> Client.AwakeableHandle.resolveSuspend(
serde: Serde<T>,
payload: T,
options: ClientRequestOptions = ClientRequestOptions.DEFAULT
): ClientResponse<Void> {
return this.resolveAsync(serde, payload, options).await()
}

suspend fun Client.AwakeableHandle.rejectSuspend(
reason: String,
options: ClientRequestOptions = ClientRequestOptions.DEFAULT
): ClientResponse<Void> {
return this.rejectAsync(reason, options).await()
}

suspend fun <T> Client.InvocationHandle<T>.attachSuspend(
options: ClientRequestOptions = ClientRequestOptions.DEFAULT
): ClientResponse<T> {
return this.attachAsync(options).await()
}

suspend fun <T : Any?> Client.InvocationHandle<T>.getOutputSuspend(
options: ClientRequestOptions = ClientRequestOptions.DEFAULT
): ClientResponse<Output<T>> {
return this.getOutputAsync(options).await()
}

suspend fun <T> Client.IdempotentInvocationHandle<T>.attachSuspend(
options: ClientRequestOptions = ClientRequestOptions.DEFAULT
): ClientResponse<T> {
return this.attachAsync(options).await()
}

suspend fun <T> Client.IdempotentInvocationHandle<T>.getOutputSuspend(
options: ClientRequestOptions = ClientRequestOptions.DEFAULT
): ClientResponse<Output<T>> {
return this.getOutputAsync(options).await()
}

suspend fun <T> Client.WorkflowHandle<T>.attachSuspend(
options: ClientRequestOptions = ClientRequestOptions.DEFAULT
): ClientResponse<T> {
return this.attachAsync(options).await()
}

suspend fun <T> Client.WorkflowHandle<T>.getOutputSuspend(
options: ClientRequestOptions = ClientRequestOptions.DEFAULT
): ClientResponse<Output<T>> {
return this.getOutputAsync(options).await()
}
20 changes: 20 additions & 0 deletions client/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
plugins {
`java-library`
`java-conventions`
`kotlin-conventions`
`library-publishing-conventions`
}

description = "Restate Client to interact with services from within other Java applications"

dependencies {
compileOnly(libs.jspecify)

api(project(":common"))

implementation(libs.jackson.core)
implementation(libs.log4j.api)

testImplementation(libs.junit.jupiter)
testImplementation(libs.assertj)
}
Loading

0 comments on commit b2d57d9

Please sign in to comment.