Interface HttpServiceInstance
- All Superinterfaces:
ServiceInstance
,Weighted
,WeightedServiceInstance
An HTTP service instance using an HTTP client Endpoint
to send HTTP requests to an HTTP server exposing a service.
An exchange must be bound to a service instance, and therefore to the underlying endpoint, using bind(UnboundExchange)
to obtain an exchange that can be sent to the remote server by
subscribing to the response publisher.
- Since:
- 1.12
- Author:
- Jeremy Kuhn
-
Method Summary
Modifier and TypeMethodDescription<T extends ExchangeContext>
Exchange<T> bind
(UnboundExchange<T> exchange) Binds the exchange to the underlying HTTPEndpoint
connecting to the service instance.long
Returns the number of active requests handled by this instance.float
Returns the current load factor of the instance.Methods inherited from interface io.inverno.mod.discovery.ServiceInstance
shutdown, shutdownGracefully
-
Method Details
-
bind
<T extends ExchangeContext> Exchange<T> bind(UnboundExchange<T> exchange) throws IllegalStateException Binds the exchange to the underlying HTTP
Endpoint
connecting to the service instance.An exchange is typically bound to a service instance right after a service instance has been resolved from a service using that same exchange (see
Service.getInstance(Object)
). Binding multiple exchanges to a service instance bypassing the service impacts load balancing and must be avoided.- Type Parameters:
T
- the exchange context type- Parameters:
exchange
- an unbound exchange- Returns:
- a bound exchange
- Throws:
IllegalStateException
- if the exchange is already bound- See Also:
-
getActiveRequests
long getActiveRequests()Returns the number of active requests handled by this instance.
- Returns:
- the number of active requests
- See Also:
-
getLoadFactor
float getLoadFactor()Returns the current load factor of the instance.
- Returns:
- the load factor between 0 and 1
- See Also:
-