Interface QueueCircuitBreakerStorage
-
- All Known Implementing Classes:
RedisQueueCircuitBreakerStorage
public interface QueueCircuitBreakerStorageProvides storage access for theQueueCircuitBreaker.- Author:
- https://github.com/mcweba [Marc-Andre Weber]
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description io.vertx.core.Future<Void>closeAllCircuits()Closes all non-closed circuits.io.vertx.core.Future<Void>closeAndRemoveCircuit(PatternAndCircuitHash patternAndCircuitHash)Closes the circuit and removes all circuit information from storage.io.vertx.core.Future<Void>closeCircuit(PatternAndCircuitHash patternAndCircuitHash)Closes the circuit.io.vertx.core.Future<io.vertx.core.json.JsonObject>getAllCircuits()Get the information (status, failRatio and circuit) of all circuits.io.vertx.core.Future<io.vertx.core.json.JsonObject>getQueueCircuitInformation(String circuitHash)Get the information (status, failRatio and circuit) of the circuit represented by the provided circuitHash.io.vertx.core.Future<QueueCircuitState>getQueueCircuitState(String circuitHash)Get the actualQueueCircuitStateof the provided circuitHash.io.vertx.core.Future<QueueCircuitState>getQueueCircuitState(PatternAndCircuitHash patternAndCircuitHash)Get the actualQueueCircuitStateof the provided patternAndCircuitHash object.io.vertx.core.Future<Void>lockQueue(String queueName, PatternAndCircuitHash patternAndCircuitHash)Mark the queueName as a locked queue of the circuit representing the provided patternAndCircuitHash.io.vertx.core.Future<String>popQueueToUnlock()Get the next queue to unlock.io.vertx.core.Future<Void>reOpenCircuit(PatternAndCircuitHash patternAndCircuitHash)Re-Opens the (half-open) circuit again.io.vertx.core.Future<Long>setOpenCircuitsToHalfOpen()Changes the status of all circuits having a status equalsQueueCircuitState.OPENtoQueueCircuitState.HALF_OPEN.io.vertx.core.Future<io.vertx.redis.client.Response>unlockSampleQueues()Get a list of sample queues of all circuits having a status equalsQueueCircuitState.HALF_OPEN.io.vertx.core.Future<UpdateStatisticsResult>updateStatistics(PatternAndCircuitHash patternAndCircuitHash, String uniqueRequestID, long timestamp, int errorThresholdPercentage, long entriesMaxAgeMS, long minQueueSampleCount, long maxQueueSampleCount, QueueResponseType queueResponseType)Updates the statistics of the corresponding circuit based on the provided patternAndCircuitHash.
-
-
-
Method Detail
-
getQueueCircuitState
io.vertx.core.Future<QueueCircuitState> getQueueCircuitState(PatternAndCircuitHash patternAndCircuitHash)
Get the actualQueueCircuitStateof the provided patternAndCircuitHash object. When no circuit could be found in the storage,QueueCircuitState.CLOSEDis returned.- Parameters:
patternAndCircuitHash- circuit information- Returns:
- returns the actual
QueueCircuitStateorQueueCircuitState.CLOSEDwhen no circuit was found
-
getQueueCircuitState
io.vertx.core.Future<QueueCircuitState> getQueueCircuitState(String circuitHash)
Get the actualQueueCircuitStateof the provided circuitHash. When no circuit could be found in the storage,QueueCircuitState.CLOSEDis returned.- Parameters:
circuitHash- the hash representing the circuit- Returns:
- returns the actual
QueueCircuitStateorQueueCircuitState.CLOSEDwhen no circuit was found
-
getQueueCircuitInformation
io.vertx.core.Future<io.vertx.core.json.JsonObject> getQueueCircuitInformation(String circuitHash)
Get the information (status, failRatio and circuit) of the circuit represented by the provided circuitHash.- Parameters:
circuitHash- the hash representing the circuit to get the informations from- Returns:
- returns a
JsonObjectcontaining the information of the circuit
-
getAllCircuits
io.vertx.core.Future<io.vertx.core.json.JsonObject> getAllCircuits()
Get the information (status, failRatio and circuit) of all circuits.- Returns:
- returns a
JsonObjectcontaining the information of all circuits
-
updateStatistics
io.vertx.core.Future<UpdateStatisticsResult> updateStatistics(PatternAndCircuitHash patternAndCircuitHash, String uniqueRequestID, long timestamp, int errorThresholdPercentage, long entriesMaxAgeMS, long minQueueSampleCount, long maxQueueSampleCount, QueueResponseType queueResponseType)
Updates the statistics of the corresponding circuit based on the provided patternAndCircuitHash.
Updating the statistics includes the following steps:
- Record uniqueRequestID as failed when queueResponseType equals
QueueResponseType.FAILURE - Record uniqueRequestID as success when queueResponseType equals
QueueResponseType.SUCCESS - Calculate failRatio based on fail/success records not older than entriesMaxAgeMS
- Change status of corresponding circuit to 'OPEN' when minQueueSampleCount and errorThresholdPercentage is reached
- Remove oldest fail/success records when maxQueueSampleCount is reached
- Parameters:
patternAndCircuitHash- the information of the circuituniqueRequestID- the unique identifier of the queued requesttimestamp- the current timestamperrorThresholdPercentage- the threshold to change status to 'OPEN' when reachedentriesMaxAgeMS- the maximum age of fail/success records to respect to calculate the failRatiominQueueSampleCount- the minimum amount of records (unique uniqueRequestIDs) to reach before status can be changedmaxQueueSampleCount- the maximum amount of fail/success records to keepqueueResponseType- theQueueResponseTyperepresenting the execution result of the queuedRequest- Returns:
- returns an
UpdateStatisticsResultobject representing the result of the statistics update
- Record uniqueRequestID as failed when queueResponseType equals
-
lockQueue
io.vertx.core.Future<Void> lockQueue(String queueName, PatternAndCircuitHash patternAndCircuitHash)
Mark the queueName as a locked queue of the circuit representing the provided patternAndCircuitHash.- Parameters:
queueName- the name of the queuepatternAndCircuitHash- the information of the circuit- Returns:
- returns a void Future when the queue could be successfully marked as locked
-
popQueueToUnlock
io.vertx.core.Future<String> popQueueToUnlock()
Get the next queue to unlock. When successful, the queue is removed from the storage.- Returns:
- returns a Future holding the name of the next queue or
nullwhen no queue was found
-
closeCircuit
io.vertx.core.Future<Void> closeCircuit(PatternAndCircuitHash patternAndCircuitHash)
Closes the circuit.
Closing the circuit includes the following steps:
- Clear statistics of this circuit
- Reset failRatio of this circuit to zero
- Set status of this circuit to 'CLOSED'
- Unlock all queues related to this circuit
- Parameters:
patternAndCircuitHash- the information of the circuit- Returns:
- returns a void Future when circuit could be closed successfully.
-
closeAndRemoveCircuit
io.vertx.core.Future<Void> closeAndRemoveCircuit(PatternAndCircuitHash patternAndCircuitHash)
Closes the circuit and removes all circuit information from storage.- Parameters:
patternAndCircuitHash- the information of the circuit- Returns:
- returns a void Future when circuit could be closed and removed successfully.
-
closeAllCircuits
io.vertx.core.Future<Void> closeAllCircuits()
Closes all non-closed circuits.
Closing all non-closed circuits includes the following steps:
- Clear statistics of all non-closed circuits
- Reset failRatio of all non-closed circuits to zero
- Set status of all non-closed circuits to 'CLOSED'
- Unlock all queues related to all non-closed circuits
- Returns:
- returns a void Future when all non-closed circuits could be closed successfully.
-
reOpenCircuit
io.vertx.core.Future<Void> reOpenCircuit(PatternAndCircuitHash patternAndCircuitHash)
Re-Opens the (half-open) circuit again. Circuits should be re-opened after a sample queue request was not successful.- Parameters:
patternAndCircuitHash- the information of the circuit- Returns:
- returns a void Future when the circuit could be re-opened successfully
-
setOpenCircuitsToHalfOpen
io.vertx.core.Future<Long> setOpenCircuitsToHalfOpen()
Changes the status of all circuits having a status equalsQueueCircuitState.OPENtoQueueCircuitState.HALF_OPEN.- Returns:
- returns a Future holding the amount of circuits updated
-
unlockSampleQueues
io.vertx.core.Future<io.vertx.redis.client.Response> unlockSampleQueues()
Get a list of sample queues of all circuits having a status equalsQueueCircuitState.HALF_OPEN. The sample queues are always the queues which have not been unlocked the longest. Each sample queue of each circuit is then updated to be the 'most recently' unlocked queue.- Returns:
- returns a Future holding a list of sample queues to unlock
-
-