@@ -32,6 +32,7 @@ one service at a time.
3232| Code-generated clients (Service) | ` Restate.service(Class) ` / ` Restate.serviceHandle(Class) ` |
3333| Code-generated clients (Virtual Object) | ` Restate.virtualObject(Class, key) ` / ` Restate.virtualObjectHandle(Class, key) ` |
3434| Code-generated clients (Workflow) | ` Restate.workflow(Class, key) ` / ` Restate.workflowHandle(Class, key) ` |
35+ | ` ctx.call(request) ` / ` ctx.send(request, delay) ` (raw ` Request ` ) | ` Restate.call(request) ` / ` Restate.send(request[, delay]) ` |
3536
3637From ** outside** a handler (the ingress client), the equivalents live on ` dev.restate.client.Client ` :
3738` client.service(Class) ` / ` client.serviceHandle(Class) ` / ` client.virtualObject(Class, key) ` / etc.
@@ -52,6 +53,7 @@ From **outside** a handler (the ingress client), the equivalents live on `dev.re
5253| Code-generated clients (Service) | ` service<T>() ` / ` toService<T>() ` |
5354| Code-generated clients (Virtual Object) | ` virtualObject<T>(key) ` / ` toVirtualObject<T>(key) ` |
5455| Code-generated clients (Workflow) | ` workflow<T>(key) ` / ` toWorkflow<T>(key) ` |
56+ | ` ctx.call(request) ` / ` ctx.send(request, delay) ` (raw ` Request ` ) | ` prepareRequest(request).call() ` / ` prepareRequest(request).send(delay) ` |
5557
5658All the top-level functions are in the ` dev.restate.sdk.kotlin ` package — add ` import dev.restate.sdk.kotlin.* ` .
5759
@@ -143,6 +145,34 @@ int idempotentCount = Restate.virtualObjectHandle(Counter.class, "my-counter")
143145 .await();
144146```
145147
148+ ### 5. Generic / dynamic-target invocation (advanced)
149+
150+ The old codegen ` <Service>Handlers ` request builders produced a ` Request ` you passed to
151+ ` ctx.call(...) ` / ` ctx.send(...) ` . Those builders are going away. When the target is only known at
152+ runtime — or you otherwise need to build a ` Request ` by hand rather than through the typed proxies
153+ above — use the generic ` Restate.call ` / ` Restate.send ` overloads:
154+
155+ ``` java
156+ // Before
157+ GreetingResponse response = ctx. call(GreeterHandlers . greet(new Greeting (" Alice" ))). await();
158+
159+ // After — build the Request manually and pass it to Restate.call / Restate.send
160+ Request<Greeting , GreetingResponse > request =
161+ Request . of(
162+ Target . service(" Greeter" , " greet" ),
163+ TypeTag . of(Greeting . class),
164+ TypeTag . of(GreetingResponse . class),
165+ new Greeting (" Alice" ))
166+ .idempotencyKey(" my-idempotency-key" )
167+ .build();
168+
169+ GreetingResponse response = Restate . call(request). await();
170+
171+ // Fire-and-forget, optionally with a delay
172+ Restate . send(request);
173+ Restate . send(request, Duration . ofMinutes(5 ));
174+ ```
175+
146176---
147177
148178## Kotlin migration
@@ -233,6 +263,37 @@ val idempotentCount = toVirtualObject<Counter>("my-counter")
233263 .await()
234264```
235265
266+ ### 5. Generic / dynamic-target invocation (advanced)
267+
268+ When the target is only known at runtime — or you otherwise need to build a ` Request ` by hand rather
269+ than through the typed ` toService ` / ` toVirtualObject ` / ` toWorkflow ` builders — wrap the ` Request `
270+ with ` prepareRequest(...) ` , which exposes the same ` options {} ` / ` call() ` / ` send() ` DSL. This
271+ replaces a raw ` ctx.call(request) ` / ` ctx.send(request, delay) ` :
272+
273+ ``` kotlin
274+ // Before
275+ val response = ctx.call(request).await()
276+
277+ // After — build the Request manually (e.g. via Request.of) and wrap it with prepareRequest
278+ val request =
279+ Request .of(
280+ Target .service(" Greeter" , " greet" ),
281+ typeTag<Greeting >(),
282+ typeTag<GreetingResponse >(),
283+ Greeting (" Alice" ),
284+ )
285+
286+ val response =
287+ prepareRequest(request)
288+ .options { idempotencyKey = " my-idempotency-key" }
289+ .call()
290+ .await()
291+
292+ // Fire-and-forget, optionally with a delay
293+ prepareRequest(request).send()
294+ prepareRequest(request).send(delay = 5 .minutes)
295+ ```
296+
236297### Kotlin gotcha: proxy clients need non-final classes
237298
238299The proxy clients (` service<T>() ` , ` virtualObject<T>(key) ` , ` toService<T>() ` , …) create a runtime proxy of
0 commit comments