You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+44-65Lines changed: 44 additions & 65 deletions
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ This SDK features:
32
32
33
33
### tl;dr Use project templates
34
34
35
-
To get started, follow the [Java quickstart](https://docs.restate.dev/get_started/quickstart).
35
+
To get started, follow the [Java quickstart](https://docs.restate.dev/get_started/quickstart?sdk=java) or the [Kotlin quickstart](https://docs.restate.dev/get_started/quickstart?sdk=kotlin).
36
36
37
37
### Setup a project (Java)
38
38
@@ -42,11 +42,15 @@ Scaffold a project using the build tool of your choice. For example, with Gradle
42
42
gradle init --type java-application
43
43
```
44
44
45
-
Add the runtime dependency [sdk-api](sdk-api) and the annotation processor dependency [sdk-api-gen](sdk-api-gen):
45
+
Add the annotation processor dependency [sdk-api-gen](sdk-api-gen), and then, depending on whether you want to deploy using HTTP or Lambda, use the appropriate dependency:
Add the runtime dependency [sdk-api-kotlin](sdk-api-kotlin) and the ksp dependency[sdk-api-gen](sdk-api-kotlin-gen):
72
+
Add the ksp dependency [sdk-api-gen](sdk-api-kotlin-gen), and then, depending on whether you want to deploy using HTTP or Lambda, use the appropriate dependency:
When using composite types/POJOs for input/output, [Jackson Databind](https://github.com/FasterXML/jackson) will be used. The Jackson dependency is not automatically included, you must add it with [`sdk-serde-jackson`](sdk-serde-jackson):
By default, [Jackson Databind](https://github.com/FasterXML/jackson) will be used for serialization/deserialization. You can override this configuration by customizing the `SerdeFactory`, check out the javadocs for more details.
112
109
113
110
### Implement your first Restate component (Kotlin)
114
111
115
112
Implement your first virtual object in a new class, for example:
116
113
117
114
```kotlin
118
-
importdev.restate.sdk.annotation.Handler
119
-
importdev.restate.sdk.annotation.VirtualObject
115
+
importdev.restate.sdk.annotation.*
120
116
importdev.restate.sdk.kotlin.*
121
117
122
118
@VirtualObject
123
119
classGreeter {
124
120
companionobject {
125
-
privatevalCOUNT=KtStateKey.json<Long>("total")
121
+
privatevalCOUNT=stateKey("total")
126
122
}
127
123
128
124
@Handler
@@ -134,33 +130,29 @@ class Greeter {
134
130
}
135
131
```
136
132
137
-
When using composite data types for input/output, [`kotlinx.serialization`](https://github.com/Kotlin/kotlinx.serialization?tab=readme-ov-file#setup) will be used.
133
+
By default [`kotlinx.serialization`](https://github.com/Kotlin/kotlinx.serialization?tab=readme-ov-file#setup) will be used for serialization/deserialization. You can override this configuration by customizing the `SerdeFactory`, check out the javadocs for more details.
138
134
139
135
### Deploy the service (HTTP Server)
140
136
141
-
To deploy the Restate service as HTTP server, add [`sdk-http-vertx`](sdk-http-vertx) to the dependencies. For example, in Gradle:
And configure the logging adding the file `resources/log4j2.properties`:
212
+
The SDK uses log4j2 as logging facade, to configure it add the file `resources/log4j2.properties`:
232
213
233
214
```
234
215
# Set to debug or trace if log4j initialization is failing
@@ -265,13 +246,15 @@ The SDK injects the following additional metadata to the logging context that ca
265
246
*`restateInvocationId`: Invocation identifier, to be used in Restate observability tools. See https://docs.restate.dev/operate/invocation#invocation-identifier.
266
247
*`restateInvocationStatus`: Invocation status, can be `WAITING_START`, `REPLAYING`, `PROCESSING`, `CLOSED`.
267
248
249
+
The dependencies `sdk-java-http`, `sdk-java-lambda`, `sdk-kotlin-http` and `sdk-kotlin-lambda` bring in `log4j-core` by default, but you can easily exclude/override that if you need to.
250
+
268
251
When assembling fat-jars, make sure to enable merging META-INF/services files. For more info, see https://github.com/apache/logging-log4j2/issues/2099.
269
252
270
253
#### Tracing with OpenTelemetry
271
254
272
-
The SDK can generate additional tracing information on top of what Restate already publishes. See https://docs.restate.dev/operate/monitoring/tracingto configure Restate tracing.
255
+
The SDK automatically propagates the OpenTelemetry `Context` from the `restate-server` into your handler. You can use that to create custom spans.
273
256
274
-
You can the additional SDK tracing information by configuring the `OpenTelemetry`in the `RestateHttpEndpointBuilder`/`LambdaRestateServer`.
257
+
To configure the `OpenTelemetry` that should be used by the SDK to publish traces, configure it in the `Endpoint.Builder` object.
275
258
276
259
For example, to set up tracing using environment variables, add the following modules to your dependencies:
Please refer to the [Opentelemetry manual instrumentation documentation](https://opentelemetry.io/docs/instrumentation/java/manual/#manual-instrumentation-setup) and the [autoconfigure documentation](https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/autoconfigure/README.md) for more info.
280
+
Please refer to the [Opentelemetry manual instrumentation documentation](https://opentelemetry.io/docs/instrumentation/java/manual/#manual-instrumentation-setup) and the [autoconfigure documentation](https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/autoconfigure/README.md) for more info.
281
+
282
+
See https://docs.restate.dev/operate/monitoring/tracing to configure Restate tracing.
298
283
299
284
## Versions
300
285
@@ -338,9 +323,3 @@ To publish local snapshots of the project:
338
323
```shell
339
324
./gradlew -DskipSigning publishToMavenLocal
340
325
```
341
-
342
-
To update the [`service-protocol`](https://github.com/restatedev/service-protocol/) git subtree:
343
-
344
-
```shell
345
-
git subtree pull --prefix sdk-core/src/main/service-protocol/ git@github.com:restatedev/service-protocol.git main --squash
0 commit comments