public class RouterClient extends Object implements Lifecycle<RouterOptions>, Health, Display
Display.DefaultPrinter, Display.Printer
Constructor and Description |
---|
RouterClient() |
Modifier and Type | Method and Description |
---|---|
CompletableFuture<Map<Endpoint,Boolean>> |
checkHealth() |
void |
display(Display.Printer out) |
boolean |
init(RouterOptions opts) |
<Req,Resp> CompletableFuture<Resp> |
invoke(Endpoint endpoint,
Req request,
Context ctx) |
<Req,Resp> CompletableFuture<Resp> |
invoke(Endpoint endpoint,
Req request,
Context ctx,
long timeoutMs)
Invoke the rpc request to the given endpoint.
|
<Req,Resp> Observer<Req> |
invokeClientStreaming(Endpoint endpoint,
Req defaultReqIns,
Context ctx,
Observer<Resp> respObserver)
Invoke a client streaming rpc request to the given endpoint.
|
<Req,Resp> void |
invokeServerStreaming(Endpoint endpoint,
Req request,
Context ctx,
Observer<Resp> observer)
Invoke a server streaming rpc request to the given endpoint.
|
CompletableFuture<Endpoint> |
route()
Gets the current routing table.
|
void |
shutdownGracefully() |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
ensureInitialized
public boolean init(RouterOptions opts)
init
in interface Lifecycle<RouterOptions>
public void shutdownGracefully()
shutdownGracefully
in interface Lifecycle<RouterOptions>
public CompletableFuture<Endpoint> route()
public <Req,Resp> CompletableFuture<Resp> invoke(Endpoint endpoint, Req request, Context ctx)
Req
- request typeResp
- response typeendpoint
- the endpoint to invokerequest
- the request to sendctx
- the contextinvoke(Endpoint, Object, Context, long)
public <Req,Resp> CompletableFuture<Resp> invoke(Endpoint endpoint, Req request, Context ctx, long timeoutMs)
Req
- request typeResp
- response typeendpoint
- the endpoint to invokerequest
- the request to sendctx
- the contexttimeoutMs
- timeout in millisecondspublic <Req,Resp> void invokeServerStreaming(Endpoint endpoint, Req request, Context ctx, Observer<Resp> observer)
Req
- the request typeResp
- the response typeendpoint
- the endpoint to invokerequest
- the request to sendctx
- the contextobserver
- the observer to receive the responsepublic <Req,Resp> Observer<Req> invokeClientStreaming(Endpoint endpoint, Req defaultReqIns, Context ctx, Observer<Resp> respObserver)
Req
- the request typeResp
- the response typeendpoint
- the endpoint to invokedefaultReqIns
- the default request instancectx
- the contextrespObserver
- the observer to receive the responsepublic void display(Display.Printer out)
public CompletableFuture<Map<Endpoint,Boolean>> checkHealth()
checkHealth
in interface Health
Copyright © 2025. All rights reserved.