Liking cljdoc? Tell your friends :D

lb.health.weights

Weight redistribution logic for health-aware load balancing. Computes effective weights based on target health status.

Weight redistribution logic for health-aware load balancing.
Computes effective weights based on target health status.
raw docstring

apply-recovery-weightsclj

(apply-recovery-weights original-weights health-statuses recovery-progress)

Apply gradual recovery weights for recently recovered targets.

original-weights: Vector of configured weights health-statuses: Vector of booleans (true = healthy) recovery-steps: Vector of integers (nil for healthy targets, 0-3 for recovering)

Returns vector of effective weights with recovery scaling applied.

Apply gradual recovery weights for recently recovered targets.

original-weights: Vector of configured weights
health-statuses: Vector of booleans (true = healthy)
recovery-steps: Vector of integers (nil for healthy targets, 0-3 for recovering)

Returns vector of effective weights with recovery scaling applied.
sourceraw docstring

compute-effective-weightsclj

(compute-effective-weights original-weights health-statuses)

Compute effective weights based on health statuses. Returns vector of weights summing to 100, with unhealthy targets at 0.

Compute effective weights based on health statuses.
Returns vector of weights summing to 100, with unhealthy targets at 0.
sourceraw docstring

compute-recovery-weightclj

(compute-recovery-weight original-weight recovery-step)

Compute the recovery weight for a target based on recovery step. recovery-step: 0-3 indicating progress through recovery-steps

Compute the recovery weight for a target based on recovery step.
recovery-step: 0-3 indicating progress through recovery-steps
sourceraw docstring

fix-weight-roundingclj

(fix-weight-rounding weights)

Ensure weights sum to exactly 100 by adjusting the largest weight. This handles rounding errors from redistribute-weights.

Ensure weights sum to exactly 100 by adjusting the largest weight.
This handles rounding errors from redistribute-weights.
sourceraw docstring

format-weight-distributionclj

(format-weight-distribution targets effective-weights)

Format weight distribution for logging.

Format weight distribution for logging.
sourceraw docstring

recovery-stepsclj

Steps for gradual weight recovery: 25%, 50%, 75%, 100%

Steps for gradual weight recovery: 25%, 50%, 75%, 100%
sourceraw docstring

redistribute-weightsclj

(redistribute-weights original-weights health-statuses)

Redistribute weights among healthy targets proportionally.

Original weights: [50, 30, 20] with targets A, B, C If B is unhealthy: A gets 50/(50+20)*100 = 71%, C gets 20/(50+20)*100 = 29% Effective weights: [71, 0, 29]

Returns a vector of effective weights (same length as original). Unhealthy targets get weight 0.

Redistribute weights among healthy targets proportionally.

Original weights: [50, 30, 20] with targets A, B, C
If B is unhealthy: A gets 50/(50+20)*100 = 71%, C gets 20/(50+20)*100 = 29%
Effective weights: [71, 0, 29]

Returns a vector of effective weights (same length as original).
Unhealthy targets get weight 0.
sourceraw docstring

update-target-group-weightsclj

(update-target-group-weights target-group health-statuses)

Create a new TargetGroup with updated effective weights. Preserves original targets but updates cumulative weights for routing.

target-group: Original TargetGroup record health-statuses: Vector of booleans (true = healthy)

Returns a new TargetGroup with updated cumulative-weights.

Create a new TargetGroup with updated effective weights.
Preserves original targets but updates cumulative weights for routing.

target-group: Original TargetGroup record
health-statuses: Vector of booleans (true = healthy)

Returns a new TargetGroup with updated cumulative-weights.
sourceraw docstring

weights->cumulativeclj

(weights->cumulative weights)

Convert individual weights to cumulative weights. Example: [50, 30, 20] -> [50, 80, 100]

Convert individual weights to cumulative weights.
Example: [50, 30, 20] -> [50, 80, 100]
sourceraw docstring

weights-changed?clj

(weights-changed? current-cumulative new-cumulative)

Check if effective weights have changed from current cumulative weights. Returns true if an update is needed.

Check if effective weights have changed from current cumulative weights.
Returns true if an update is needed.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close