All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.smallrye.stork.api.LoadBalancer Maven / Gradle / Ivy

Go to download

Main Stork API classes. You are likely to need `smallrye-stork-core` and not this module.

The newest version!
package io.smallrye.stork.api;

import java.util.Collection;

/**
 * Works with a single service name.
 * Provides a single service instance.
 * 
* Must be non-blocking */ public interface LoadBalancer { /** * Select a single {@link ServiceInstance} from the given list. * * @param serviceInstances instances to choose from * * @return a ServiceInstance * * @throws NoServiceInstanceFoundException if the incoming collection is empty or all the service instances in the * collection * are deemed invalid for some reason */ ServiceInstance selectServiceInstance(Collection serviceInstances); /** * LoadBalancers often record information of the calls being made with instances they return, be it inflight requests, * response time, etc. *
* These calculations often assume that an operation using a previously selected service instance is marked * as started before the next instance selection. This prevents a situation in which multiple parallel invocations * of the LoadBalancer return the same service instance (because they have the same input for selection). *
* If the load balancer is insusceptible of this problem, this method should return false. * * @return true if the selecting service instance should be called atomically with marking the operation as started * * @see Service#selectInstanceAndRecordStart(boolean) * @see Service#selectInstanceAndRecordStart(Collection, boolean) */ default boolean requiresStrictRecording() { return true; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy