Package io.smallrye.stork.api
Interface ServiceInstance
public interface ServiceInstance
Represents an instance of service.
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleangetHost()longgetId()default Metadata<? extends MetadataKey>getPath()For service behind an API gateway or a proxy, this method return the path.intgetPort()booleanisSecure()default voidWhengatherStatisticsis enabled, reports the end of an operation using this service instance.default voidWhengatherStatisticsis enabled, reports a reply for an operation using this service instance.default voidrecordStart(boolean measureTime) Warning Usually should not be called directly.
-
Method Details
-
getId
long getId()- Returns:
- the service id. The service ids are unique per Stork instance.
-
getHost
String getHost()- Returns:
- the host of the service.
-
getPort
int getPort()- Returns:
- the port of the service.
-
getPath
For service behind an API gateway or a proxy, this method return the path. When set, the final location of the service is composed of$host:$port/$path.- Returns:
- the path if any.
-
isSecure
boolean isSecure()- Returns:
- whether the communication should happen over a secure connection
-
getMetadata
- Returns:
- the metadata of the instance, empty if none.
-
getLabels
- Returns:
- the labels of the instance, empty if none.
-
gatherStatistics
default boolean gatherStatistics()- Returns:
- whether the interaction with the service are monitored, allowing statistic-based load-balancing.
-
recordStart
default void recordStart(boolean measureTime) Warning Usually should not be called directly. Most client libraries should useService.selectInstanceAndRecordStart(Collection, boolean)andService.selectInstanceAndRecordStart(boolean)to select services. These methods invoke this method automatically
WhengatherStatisticsis enabled, reports the start of an operation using this service instance.The load balancers that keep track of inflight operations should increase the counter on this method. The load balancer that collect times of operations should only take into account operations that have
measureTimeset totrue- Parameters:
measureTime- if true,recordReply()will be called for this operation
-
recordReply
default void recordReply()WhengatherStatisticsis enabled, reports a reply for an operation using this service instance.Should be called if and only if
recordStart(true)has been called earlier -
recordEnd
WhengatherStatisticsis enabled, reports the end of an operation using this service instance.- Parameters:
failure- if the operation failed, the throwable depicting the failure,nullotherwise
-