Interface Client
- All Known Implementing Classes:
BaseClient,JdkClient
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceThis class represents a handle to an Awakeable.static interfacestatic interfacestatic interface -
Method Summary
Modifier and TypeMethodDescriptionCreate a newClient.AwakeableHandlefor the provided identifier.default <Req,Res> Response <Res> Call a service and wait for the response.<Req,Res> CompletableFuture <Response<Res>> Future version ofcall(Request)static ClientCreate a default JDK client.static Clientconnect(String baseUri, RequestOptions options) Create a default JDK client.static Clientconnect(String baseUri, SerdeFactory serdeFactory) Create a default JDK client.static Clientconnect(String baseUri, SerdeFactory serdeFactory, RequestOptions options) Create a default JDK client.<Res> Client.IdempotentInvocationHandle<Res> idempotentInvocationHandle(Target target, String idempotencyKey, TypeTag<Res> resTypeTag) Create a newClient.IdempotentInvocationHandlefor the provided target and idempotency key.default <Res> Client.IdempotentInvocationHandle<Res> idempotentInvocationHandle(Target target, String idempotencyKey, Class<Res> clazz) Create a newClient.IdempotentInvocationHandlefor the provided target and idempotency key.<Res> Client.InvocationHandle<Res> invocationHandle(String invocationId, TypeTag<Res> resTypeTag) Create a newClient.InvocationHandlefor the provided invocation identifier.default <Res> Client.InvocationHandle<Res> invocationHandle(String invocationId, Class<Res> clazz) Create a newClient.InvocationHandlefor the provided invocation identifier.default <Req,Res> SendResponse <Res> Send a request to a service without waiting for the response.default <Req,Res> SendResponse <Res> Send a request to a service without waiting for the response, optionally providing an execution delay to wait for.default <Req,Res> CompletableFuture <SendResponse<Res>> Future version ofsend(Request)<Req,Res> CompletableFuture <SendResponse<Res>> Future version ofsend(Request, Duration)default <SVC> SVCEXPERIMENTAL API: Simple API to invoke a Restate service from the ingress.default <SVC> ClientServiceHandle<SVC> serviceHandle(Class<SVC> clazz) EXPERIMENTAL API: Advanced API to invoke a Restate service from the ingress with full control.default <Req,Res> SendResponse <Res> submit(WorkflowRequest<Req, Res> request) Submit a workflow.default <Req,Res> SendResponse <Res> submit(WorkflowRequest<Req, Res> request, @Nullable Duration delay) Submit a workflow, optionally providing an execution delay to wait for.default <Req,Res> CompletableFuture <SendResponse<Res>> submitAsync(WorkflowRequest<Req, Res> request) Future version ofsubmit(WorkflowRequest)default <Req,Res> CompletableFuture <SendResponse<Res>> submitAsync(WorkflowRequest<Req, Res> request, @Nullable Duration delay) Future version ofsubmit(WorkflowRequest, Duration)default <SVC> SVCvirtualObject(Class<SVC> clazz, String key) EXPERIMENTAL API: Simple API to invoke a Restate Virtual Object from the ingress.default <SVC> ClientServiceHandle<SVC> virtualObjectHandle(Class<SVC> clazz, String key) EXPERIMENTAL API: Advanced API to invoke a Restate Virtual Object from the ingress with full control.default <SVC> SVCEXPERIMENTAL API: Simple API to invoke a Restate Workflow from the ingress.default <SVC> ClientServiceHandle<SVC> workflowHandle(Class<SVC> clazz, String key) EXPERIMENTAL API: Advanced API to invoke a Restate Workflow from the ingress with full control.<Res> Client.WorkflowHandle<Res> workflowHandle(String workflowName, String workflowId, TypeTag<Res> resTypeTag) Create a newClient.WorkflowHandlefor the provided workflow name and identifier.default <Res> Client.WorkflowHandle<Res> workflowHandle(String workflowName, String workflowId, Class<Res> clazz) Create a newClient.WorkflowHandlefor the provided workflow name and identifier.
-
Method Details
-
callAsync
Future version ofcall(Request)- See Also:
-
call
Call a service and wait for the response.- Throws:
IngressException
-
sendAsync
Future version ofsend(Request)- See Also:
-
send
Send a request to a service without waiting for the response.- Throws:
IngressException
-
sendAsync
<Req,Res> CompletableFuture<SendResponse<Res>> sendAsync(Request<Req, Res> request, @Nullable Duration delay) Future version ofsend(Request, Duration)- See Also:
-
send
default <Req,Res> SendResponse<Res> send(Request<Req, Res> request, @Nullable Duration delay) throws IngressExceptionSend a request to a service without waiting for the response, optionally providing an execution delay to wait for.- Throws:
IngressException
-
submitAsync
default <Req,Res> CompletableFuture<SendResponse<Res>> submitAsync(WorkflowRequest<Req, Res> request) Future version ofsubmit(WorkflowRequest)- See Also:
-
submit
default <Req,Res> SendResponse<Res> submit(WorkflowRequest<Req, Res> request) throws IngressExceptionSubmit a workflow.- Throws:
IngressException
-
submitAsync
default <Req,Res> CompletableFuture<SendResponse<Res>> submitAsync(WorkflowRequest<Req, Res> request, @Nullable Duration delay) Future version ofsubmit(WorkflowRequest, Duration)- See Also:
-
submit
default <Req,Res> SendResponse<Res> submit(WorkflowRequest<Req, Res> request, @Nullable Duration delay) throws IngressExceptionSubmit a workflow, optionally providing an execution delay to wait for.- Throws:
IngressException
-
awakeableHandle
Create a newClient.AwakeableHandlefor the provided identifier. You can use it toClient.AwakeableHandle.resolve(TypeTag, Object)orClient.AwakeableHandle.reject(String)an Awakeable from the ingress. -
invocationHandle
Create a newClient.InvocationHandlefor the provided invocation identifier.- Parameters:
invocationId- the invocation identifierresTypeTag- type tag used to deserialize the invocation result- Returns:
- the invocation handle
-
invocationHandle
Create a newClient.InvocationHandlefor the provided invocation identifier.- Parameters:
invocationId- the invocation identifierclazz- used to deserialize the invocation result- Returns:
- the invocation handle
-
idempotentInvocationHandle
<Res> Client.IdempotentInvocationHandle<Res> idempotentInvocationHandle(Target target, String idempotencyKey, TypeTag<Res> resTypeTag) Create a newClient.IdempotentInvocationHandlefor the provided target and idempotency key.- Parameters:
target- the target service/methodidempotencyKey- the idempotency keyresTypeTag- type tag used to deserialize the invocation result- Returns:
- the idempotent invocation handle
-
idempotentInvocationHandle
default <Res> Client.IdempotentInvocationHandle<Res> idempotentInvocationHandle(Target target, String idempotencyKey, Class<Res> clazz) Create a newClient.IdempotentInvocationHandlefor the provided target and idempotency key.- Parameters:
target- the target service/methodidempotencyKey- the idempotency keyclazz- used to deserialize the invocation result- Returns:
- the idempotent invocation handle
-
workflowHandle
<Res> Client.WorkflowHandle<Res> workflowHandle(String workflowName, String workflowId, TypeTag<Res> resTypeTag) Create a newClient.WorkflowHandlefor the provided workflow name and identifier.- Parameters:
workflowName- the workflow nameworkflowId- the workflow identifierresTypeTag- type tag used to deserialize the invocation result- Returns:
- the workflow handle
-
workflowHandle
default <Res> Client.WorkflowHandle<Res> workflowHandle(String workflowName, String workflowId, Class<Res> clazz) Create a newClient.WorkflowHandlefor the provided workflow name and identifier.- Parameters:
workflowName- the workflow nameworkflowId- the workflow identifierclazz- used to deserialize the workflow result- Returns:
- the workflow handle
-
service
EXPERIMENTAL API: Simple API to invoke a Restate service from the ingress.Create a proxy client that allows calling service methods directly and synchronously, returning just the output (not wrapped in
Response). This is the recommended approach for straightforward request-response interactions.Client client = Client.connect("http://localhost:8080"); var greeterProxy = client.service(Greeter.class); GreetingResponse output = greeterProxy.greet(new Greeting("Alice"));For advanced use cases requiring asynchronous request handling, access to
Responsemetadata, or invocation options (such as idempotency keys), useserviceHandle(Class)instead.- Parameters:
clazz- the service class annotated withService- Returns:
- a proxy client to invoke the service
-
serviceHandle
EXPERIMENTAL API: Advanced API to invoke a Restate service from the ingress with full control.Create a handle that provides advanced invocation capabilities including:
- Async request handling with
CompletableFuture - Invocation options such as idempotency keys
- Fire-and-forget requests via
send() - Access to full
Responsemetadata
Client client = Client.connect("http://localhost:8080"); // Use call() with method reference and wait for the result Response<GreetingResponse> response = client.serviceHandle(Greeter.class) .call(Greeter::greet, new Greeting("Alice")); // Use send() for one-way invocation without waiting SendResponse<GreetingResponse> sendResponse = client.serviceHandle(Greeter.class) .send(Greeter::greet, new Greeting("Alice"));For simple synchronous request-response interactions, consider using
service(Class)instead.- Parameters:
clazz- the service class annotated withService- Returns:
- a handle to invoke the service with advanced options
- Async request handling with
-
virtualObject
EXPERIMENTAL API: Simple API to invoke a Restate Virtual Object from the ingress.Create a proxy client that allows calling virtual object methods directly and synchronously, returning just the output (not wrapped in
Response). This is the recommended approach for straightforward request-response interactions.Client client = Client.connect("http://localhost:8080"); var counterProxy = client.virtualObject(Counter.class, "my-counter"); int count = counterProxy.increment();For advanced use cases requiring asynchronous request handling, access to
Responsemetadata, or invocation options (such as idempotency keys), usevirtualObjectHandle(Class, String)instead.- Parameters:
clazz- the virtual object class annotated withVirtualObjectkey- the key identifying the specific virtual object instance- Returns:
- a proxy client to invoke the virtual object
-
virtualObjectHandle
@Experimental default <SVC> ClientServiceHandle<SVC> virtualObjectHandle(Class<SVC> clazz, String key) EXPERIMENTAL API: Advanced API to invoke a Restate Virtual Object from the ingress with full control.Create a handle that provides advanced invocation capabilities including:
- Async request handling with
CompletableFuture - Invocation options such as idempotency keys
- Fire-and-forget requests via
send() - Access to full
Responsemetadata
Client client = Client.connect("http://localhost:8080"); // Use call() with method reference and wait for the result Response<Integer> response = client.virtualObjectHandle(Counter.class, "my-counter") .call(Counter::increment); // Use send() for one-way invocation without waiting SendResponse<Integer> sendResponse = client.virtualObjectHandle(Counter.class, "my-counter") .send(Counter::increment);For simple synchronous request-response interactions, consider using
virtualObject(Class, String)instead.- Parameters:
clazz- the virtual object class annotated withVirtualObjectkey- the key identifying the specific virtual object instance- Returns:
- a handle to invoke the virtual object with advanced options
- Async request handling with
-
workflow
EXPERIMENTAL API: Simple API to invoke a Restate Workflow from the ingress.Create a proxy client that allows calling workflow methods directly and synchronously, returning just the output (not wrapped in
Response). This is the recommended approach for straightforward request-response interactions.Client client = Client.connect("http://localhost:8080"); var workflowProxy = client.workflow(OrderWorkflow.class, "order-123"); OrderResult result = workflowProxy.start(new OrderRequest(...));For advanced use cases requiring asynchronous request handling, access to
Responsemetadata, or invocation options (such as idempotency keys), useworkflowHandle(Class, String)instead.- Parameters:
clazz- the workflow class annotated withWorkflowkey- the key identifying the specific workflow instance- Returns:
- a proxy client to invoke the workflow
-
workflowHandle
EXPERIMENTAL API: Advanced API to invoke a Restate Workflow from the ingress with full control.Create a handle that provides advanced invocation capabilities including:
- Async request handling with
CompletableFuture - Invocation options such as idempotency keys
- Fire-and-forget requests via
send() - Access to full
Responsemetadata
Client client = Client.connect("http://localhost:8080"); // Use call() with method reference and wait for the result Response<OrderResult> response = client.workflowHandle(OrderWorkflow.class, "order-123") .call(OrderWorkflow::start, new OrderRequest(...)); // Use send() for one-way invocation without waiting SendResponse<OrderResult> sendResponse = client.workflowHandle(OrderWorkflow.class, "order-123") .send(OrderWorkflow::start, new OrderRequest(...));For simple synchronous request-response interactions, consider using
workflow(Class, String)instead.- Parameters:
clazz- the workflow class annotated withWorkflowkey- the key identifying the specific workflow instance- Returns:
- a handle to invoke the workflow with advanced options
- Async request handling with
-
connect
Create a default JDK client.- Parameters:
baseUri- uri to connect to.
-
connect
Create a default JDK client.- Parameters:
baseUri- uri to connect tooptions- default options to use in all the requests.
-
connect
Create a default JDK client.- Parameters:
baseUri- uri to connect toserdeFactory- Serde factory to use. If you're just wrapping this client in a code-generated client, you don't need to provide this parameter.
-
connect
Create a default JDK client.- Parameters:
baseUri- uri to connect toserdeFactory- Serde factory to use. If you're just wrapping this client in a code-generated client, you don't need to provide this parameter.options- default options to use in all the requests.
-