public class Service
extends java.lang.Object
ServiceEndpoint
When multiple instances of a service endpoints are active they work in a queue, meaning only one listener responds to any given request.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_SERVICE_PREFIX |
static java.lang.String |
SRV_INFO |
static java.lang.String |
SRV_PING |
static java.lang.String |
SRV_STATS |
Modifier and Type | Method and Description |
---|---|
static ServiceBuilder |
builder()
Get an instance of a ServiceBuilder.
|
java.lang.String |
getDescription()
Get the description of the service
|
java.time.Duration |
getDrainTimeout()
Get the drain timeout setting
|
EndpointStats |
getEndpointStats(java.lang.String endpointName)
Get the up-to-date
EndpointStats for a specific endpoint |
java.lang.String |
getId()
Get the id of the service
|
InfoResponse |
getInfoResponse()
Get the pre-constructed info response.
|
java.lang.String |
getName()
Get the name of the service
|
PingResponse |
getPingResponse()
Get the pre-constructed ping response.
|
StatsResponse |
getStatsResponse()
Get the up-to-date stats response which contains a list of all
EndpointStats |
java.lang.String |
getVersion()
Get the version of the service
|
void |
reset()
Reset the statistics for the endpoints
|
java.util.concurrent.CompletableFuture<java.lang.Boolean> |
startService()
Start the service
|
void |
stop()
Stop the service by draining.
|
void |
stop(boolean drain)
Stop the service, optionally draining.
|
void |
stop(boolean drain,
java.lang.Throwable t)
Stop the service, optionally draining and optionally with an error cause
|
void |
stop(java.lang.Throwable t)
Stop the service by draining.
|
java.lang.String |
toString() |
public static final java.lang.String SRV_PING
public static final java.lang.String SRV_INFO
public static final java.lang.String SRV_STATS
public static final java.lang.String DEFAULT_SERVICE_PREFIX
public java.util.concurrent.CompletableFuture<java.lang.Boolean> startService()
public static ServiceBuilder builder()
public void stop()
public void stop(java.lang.Throwable t)
t
- the error causepublic void stop(boolean drain)
drain
- the flag indicating to drain or notpublic void stop(boolean drain, java.lang.Throwable t)
drain
- the flag indicating to drain or nott
- the optional error cause. If supplied, mark the future that was received from the start method that the service completed exceptionallypublic void reset()
public java.lang.String getId()
public java.lang.String getName()
public java.lang.String getVersion()
public java.lang.String getDescription()
public java.time.Duration getDrainTimeout()
public PingResponse getPingResponse()
public InfoResponse getInfoResponse()
public StatsResponse getStatsResponse()
EndpointStats
public EndpointStats getEndpointStats(java.lang.String endpointName)
EndpointStats
for a specific endpointendpointName
- the endpoint namepublic java.lang.String toString()
toString
in class java.lang.Object