-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now sdk-api-kotlin works again with the new interface system. Fix #237
- Loading branch information
1 parent
d2ec402
commit b29f181
Showing
48 changed files
with
907 additions
and
1,090 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 0 additions & 60 deletions
60
examples/src/main/kotlin/dev/restate/sdk/examples/CounterKt.kt
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
examples/src/main/kotlin/my/restate/sdk/examples/Counter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// 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 my.restate.sdk.examples | ||
|
||
import dev.restate.sdk.common.StateKey | ||
import dev.restate.sdk.http.vertx.RestateHttpEndpointBuilder | ||
import dev.restate.sdk.kotlin.Component | ||
import dev.restate.sdk.kotlin.KtSerdes | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable data class CounterUpdate(var oldValue: Long, val newValue: Long) | ||
|
||
private val totalKey = StateKey.of<Long>("total", KtSerdes.json()) | ||
|
||
val counter = | ||
Component.virtualObject("Counter") { | ||
handler("reset") { ctx, _: Unit -> ctx.clear(totalKey) } | ||
handler("add") { ctx, value: Long -> | ||
val currentValue = ctx.get(totalKey) ?: 0L | ||
val newValue = currentValue + value | ||
ctx.set(totalKey, newValue) | ||
} | ||
handler("get") { ctx, _: Unit -> ctx.get(totalKey) ?: 0L } | ||
handler("getAndAdd") { ctx, value: Long -> | ||
val currentValue = ctx.get(totalKey) ?: 0L | ||
val newValue = currentValue + value | ||
ctx.set(totalKey, newValue) | ||
CounterUpdate(currentValue, newValue) | ||
} | ||
} | ||
|
||
fun main() { | ||
RestateHttpEndpointBuilder.builder().with(counter).buildAndListen() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.