private int getBoundedRecommendationForScaleUp()

in src/main/java/com/google/cloud/run/kafkascaler/ScalingStabilizer.java [204:229]


  private int getBoundedRecommendationForScaleUp(
      Behavior behavior,
      Instant time,
      int currentInstanceCount,
      int recommendedInstances,
      BoundsDebugInfo debug) {
    if (behavior.scaleUp() == null) {
      return recommendedInstances;
    }

    Scaling scaleUp = behavior.scaleUp();
    Optional<Integer> stabilizationBound =
        stabilizeRecommendation(behavior, time, currentInstanceCount, recommendedInstances, debug);
    Optional<Integer> rateLimitBound =
        rateLimitScaleUpRecommendation(time, currentInstanceCount, scaleUp, debug);

    int scaleUpBound = recommendedInstances;
    if (stabilizationBound.isPresent()) {
      scaleUpBound = min(stabilizationBound.get(), scaleUpBound);
    }
    if (rateLimitBound.isPresent()) {
      scaleUpBound = min(rateLimitBound.get(), scaleUpBound);
    }

    return scaleUpBound;
  }