Skip to content

Commit 20970d2

Browse files
Rename types package to common (#488)
* Few renamings to reduce breakage, plus improve javadocs of `Context` * Reintroduce RestateHttpEndpointBuilder to reduce breakage * Reintroduce JsonSerdes to reduce breakage * Javadocs cosmetics
1 parent 58e83b2 commit 20970d2

File tree

83 files changed

+710
-349
lines changed

Some content is hidden

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

83 files changed

+710
-349
lines changed

examples/src/main/java/my/restate/sdk/examples/Counter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
import dev.restate.sdk.annotation.Name;
1414
import dev.restate.sdk.annotation.Shared;
1515
import dev.restate.sdk.annotation.VirtualObject;
16+
import dev.restate.sdk.common.StateKey;
1617
import dev.restate.sdk.endpoint.Endpoint;
1718
import dev.restate.sdk.http.vertx.RestateHttpServer;
18-
import dev.restate.sdk.types.StateKey;
1919
import java.time.Duration;
2020
import org.apache.logging.log4j.LogManager;
2121
import org.apache.logging.log4j.Logger;

examples/src/main/java/my/restate/sdk/examples/LoanWorkflow.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
import dev.restate.sdk.annotation.Service;
1616
import dev.restate.sdk.annotation.Shared;
1717
import dev.restate.sdk.annotation.Workflow;
18+
import dev.restate.sdk.common.DurablePromiseKey;
19+
import dev.restate.sdk.common.StateKey;
20+
import dev.restate.sdk.common.TerminalException;
1821
import dev.restate.sdk.endpoint.Endpoint;
1922
import dev.restate.sdk.http.vertx.RestateHttpServer;
20-
import dev.restate.sdk.types.DurablePromiseKey;
21-
import dev.restate.sdk.types.StateKey;
22-
import dev.restate.sdk.types.TerminalException;
2323
import java.math.BigDecimal;
2424
import java.time.Duration;
2525
import java.time.Instant;

examples/src/main/kotlin/my/restate/sdk/examples/CounterKt.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import kotlinx.serialization.Serializable
1818
import org.apache.logging.log4j.LogManager
1919
import org.apache.logging.log4j.Logger
2020

21-
@Serializable data class CounterUpdate(var oldValue: Long, val newValue: Long)
22-
2321
@VirtualObject
2422
class CounterKt {
2523

@@ -28,6 +26,8 @@ class CounterKt {
2826
private val LOG: Logger = LogManager.getLogger(CounterKt::class.java)
2927
}
3028

29+
@Serializable data class CounterUpdate(var oldValue: Long, val newValue: Long)
30+
3131
@Handler
3232
suspend fun reset(ctx: ObjectContext) {
3333
ctx.clear(TOTAL)

sdk-api-gen/src/main/resources/templates/Client.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import dev.restate.sdk.CallDurableFuture;
44
import dev.restate.sdk.Context;
5-
import dev.restate.sdk.types.StateKey;
5+
import dev.restate.sdk.common.StateKey;
66
import dev.restate.serde.Serde;
77
import dev.restate.common.Target;
88
import java.util.Optional;

sdk-api-kotlin/src/main/kotlin/dev/restate/sdk/kotlin/ContextImpl.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ package dev.restate.sdk.kotlin
1111
import dev.restate.common.Output
1212
import dev.restate.common.Request
1313
import dev.restate.common.Slice
14+
import dev.restate.sdk.common.DurablePromiseKey
15+
import dev.restate.sdk.common.HandlerRequest
16+
import dev.restate.sdk.common.StateKey
17+
import dev.restate.sdk.common.TerminalException
1418
import dev.restate.sdk.endpoint.definition.HandlerContext
15-
import dev.restate.sdk.types.DurablePromiseKey
16-
import dev.restate.sdk.types.HandlerRequest
17-
import dev.restate.sdk.types.StateKey
18-
import dev.restate.sdk.types.TerminalException
1919
import dev.restate.serde.Serde
2020
import dev.restate.serde.SerdeFactory
2121
import dev.restate.serde.TypeTag
@@ -127,7 +127,7 @@ internal constructor(
127127
var coroutineCtx = currentCoroutineContext()
128128
val javaRetryPolicy =
129129
retryPolicy?.let {
130-
dev.restate.sdk.types.RetryPolicy.exponential(
130+
dev.restate.sdk.common.RetryPolicy.exponential(
131131
it.initialDelay.toJavaDuration(), it.exponentiationFactor)
132132
.setMaxAttempts(it.maxAttempts)
133133
.setMaxDelay(it.maxDelay?.toJavaDuration())
@@ -165,7 +165,7 @@ internal constructor(
165165
}
166166

167167
override fun random(): RestateRandom {
168-
return RestateRandom(handlerContext.request().invocationId().toRandomSeed())
168+
return RestateRandom(handlerContext.request().getInvocationId().toRandomSeed())
169169
}
170170

171171
override fun <T : Any> promise(key: DurablePromiseKey<T>): DurablePromise<T> {

sdk-api-kotlin/src/main/kotlin/dev/restate/sdk/kotlin/HandlerRunner.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
package dev.restate.sdk.kotlin
1010

1111
import dev.restate.common.Slice
12+
import dev.restate.sdk.common.TerminalException
1213
import dev.restate.sdk.endpoint.definition.HandlerContext
13-
import dev.restate.sdk.types.TerminalException
1414
import dev.restate.serde.Serde
1515
import dev.restate.serde.SerdeFactory
1616
import io.opentelemetry.extension.kotlin.asContextElement
@@ -108,7 +108,7 @@ internal constructor(
108108
options.coroutineContext +
109109
dev.restate.sdk.endpoint.definition.HandlerRunner.HANDLER_CONTEXT_THREAD_LOCAL
110110
.asContextElement(handlerContext) +
111-
handlerContext.request().otelContext()!!.asContextElement())
111+
handlerContext.request().getOpenTelemetryContext()!!.asContextElement())
112112

113113
val completableFuture = CompletableFuture<Slice>()
114114
val job =

sdk-api-kotlin/src/main/kotlin/dev/restate/sdk/kotlin/api.kt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ package dev.restate.sdk.kotlin
1010

1111
import dev.restate.common.Output
1212
import dev.restate.common.Request
13-
import dev.restate.sdk.types.DurablePromiseKey
14-
import dev.restate.sdk.types.HandlerRequest
15-
import dev.restate.sdk.types.StateKey
16-
import dev.restate.sdk.types.TerminalException
13+
import dev.restate.sdk.common.DurablePromiseKey
14+
import dev.restate.sdk.common.HandlerRequest
15+
import dev.restate.sdk.common.StateKey
16+
import dev.restate.sdk.common.TerminalException
1717
import dev.restate.serde.TypeTag
1818
import dev.restate.serde.kotlinx.*
1919
import java.util.*
@@ -173,7 +173,7 @@ sealed interface Context {
173173

174174
/**
175175
* Create a [RestateRandom] instance inherently predictable, seeded on the
176-
* [dev.restate.sdk.types.InvocationId], which is not secret.
176+
* [dev.restate.sdk.common.InvocationId], which is not secret.
177177
*
178178
* This instance is useful to generate identifiers, idempotency keys, and for uniform sampling
179179
* from a set of options. If a cryptographically secure value is needed, please generate that
@@ -394,7 +394,7 @@ class RestateRandom(seed: Long) : Random() {
394394
* waits until the asynchronous result is available.
395395
*
396396
* The result can be either a success or a failure. In case of a failure, [await] will throw a
397-
* [dev.restate.sdk.types.TerminalException].
397+
* [dev.restate.sdk.common.TerminalException].
398398
*
399399
* @param T type of this future's result
400400
*/
@@ -408,14 +408,14 @@ sealed interface DurableFuture<T> {
408408
suspend fun await(): T
409409

410410
/**
411-
* Same as [await] but throws a [dev.restate.sdk.types.TimeoutException] if this [DurableFuture]
411+
* Same as [await] but throws a [dev.restate.sdk.common.TimeoutException] if this [DurableFuture]
412412
* doesn't complete before the provided `timeout`.
413413
*/
414414
suspend fun await(duration: Duration): T
415415

416416
/**
417-
* Creates a [DurableFuture] that throws a [dev.restate.sdk.types.TimeoutException] if this future
418-
* doesn't complete before the provided `timeout`.
417+
* Creates a [DurableFuture] that throws a [dev.restate.sdk.common.TimeoutException] if this
418+
* future doesn't complete before the provided `timeout`.
419419
*/
420420
suspend fun withTimeout(duration: Duration): DurableFuture<T>
421421

@@ -426,7 +426,7 @@ sealed interface DurableFuture<T> {
426426
* Map the success result of this [DurableFuture].
427427
*
428428
* @param transform the mapper to execute if this [DurableFuture] completes with success. The
429-
* mapper can throw a [dev.restate.sdk.types.TerminalException], thus failing the returned
429+
* mapper can throw a [dev.restate.sdk.common.TerminalException], thus failing the returned
430430
* [DurableFuture].
431431
* @return a new [DurableFuture] with the mapped result, when completed
432432
*/
@@ -436,10 +436,10 @@ sealed interface DurableFuture<T> {
436436
* Map both the success and the failure result of this [DurableFuture].
437437
*
438438
* @param transformSuccess the mapper to execute if this [DurableFuture] completes with success.
439-
* The mapper can throw a [dev.restate.sdk.types.TerminalException], thus failing the returned
439+
* The mapper can throw a [dev.restate.sdk.common.TerminalException], thus failing the returned
440440
* [DurableFuture].
441441
* @param transformFailure the mapper to execute if this [DurableFuture] completes with failure.
442-
* The mapper can throw a [dev.restate.sdk.types.TerminalException], thus failing the returned
442+
* The mapper can throw a [dev.restate.sdk.common.TerminalException], thus failing the returned
443443
* [DurableFuture].
444444
* @return a new [DurableFuture] with the mapped result, when completed
445445
*/
@@ -452,7 +452,7 @@ sealed interface DurableFuture<T> {
452452
* Map the failure result of this [DurableFuture].
453453
*
454454
* @param transform the mapper to execute if this [DurableFuture] completes with failure. The
455-
* mapper can throw a [dev.restate.sdk.types.TerminalException], thus failing the returned
455+
* mapper can throw a [dev.restate.sdk.common.TerminalException], thus failing the returned
456456
* [DurableFuture].
457457
* @return a new [DurableFuture] with the mapped result, when completed
458458
*/

sdk-api-kotlin/src/main/kotlin/dev/restate/sdk/kotlin/futures.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ package dev.restate.sdk.kotlin
1010

1111
import dev.restate.common.Output
1212
import dev.restate.common.Slice
13+
import dev.restate.sdk.common.TerminalException
14+
import dev.restate.sdk.common.TimeoutException
1315
import dev.restate.sdk.endpoint.definition.AsyncResult
1416
import dev.restate.sdk.endpoint.definition.HandlerContext
15-
import dev.restate.sdk.types.TerminalException
16-
import dev.restate.sdk.types.TimeoutException
1717
import dev.restate.serde.Serde
1818
import dev.restate.serde.TypeTag
1919
import java.util.concurrent.CompletableFuture

0 commit comments

Comments
 (0)