Package io.smallrye.stork.api
Interface ServiceInstance
-
public interface ServiceInstanceRepresents an instance of service.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default booleangatherStatistics()StringgetHost()longgetId()default Map<String,String>getLabels()default Metadata<? extends MetadataKey>getMetadata()intgetPort()booleanisSecure()default voidrecordEnd(Throwable failure)WhengatherStatisticsis enabled, reports the end of an operation using this service instance.default voidrecordReply()WhengatherStatisticsis enabled, reports a reply for an operation using this service instance.default voidrecordStart(boolean measureTime)Warning
-
-
-
Method Detail
-
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.
-
isSecure
boolean isSecure()
- Returns:
- whether the communication should happen over a secure connection
-
getMetadata
default Metadata<? extends MetadataKey> getMetadata()
- Returns:
- the metadata of the instance, empty if none.
-
getLabels
default Map<String,String> 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 havemeasureTimeset 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 ifrecordStart(true)has been called earlier
-
recordEnd
default void recordEnd(Throwable failure)
WhengatherStatisticsis enabled, reports the end of an operation using this service instance.- Parameters:
failure- if the operation failed, the throwable depicting the failure,nullotherwise
-
-