Packages

final class AckDeadlineDistribution extends AnyRef

Tracks message processing latencies and computes an adaptive ack deadline based on the percentile of observed processing times.

The percentile computation uses the nearest-rank method, matching the implementation in Google's com.google.api.gax.core.Distribution class. Google's MessageDispatcher uses a 99.9th percentile by default; this class defaults to the same.

Pass the same instance to autoExtendAckDeadlines (which reads the computed deadline) and to the acknowledge/nack operators (which record completion times).

Usage:

val dist = AckDeadlineDistribution(
  initialDeadlineSeconds = 10,
  minDeadlineSeconds = 10,
  maxDeadlineSeconds = 600)

GooglePubSub.subscribe(request, 1.second)
  .via(GooglePubSub.autoExtendAckDeadlines(subscriptionFqrs, 3.seconds, dist))
  .mapAsync(4)(processMessage)
  .map(msg => AcknowledgeRequest(sub, Seq(msg.ackId)))
  .to(GooglePubSub.acknowledge(parallelism = 1, dist))
Annotations
@ApiMayChange()
Source
AckDeadlineDistribution.scala
Since

2.0.0

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. AckDeadlineDistribution
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
  6. def currentDeadlineSeconds: Int

    Get the current adaptive deadline in seconds, based on the configured percentile of observed processing times.

    Get the current adaptive deadline in seconds, based on the configured percentile of observed processing times. Returns initialDeadlineSeconds if no observations yet.

    Uses the nearest-rank method, matching com.google.api.gax.core.Distribution.getPercentile:

    long targetRank = (long) Math.ceil(percentile * count.get() / 100);
    long rank = 0;
    for (int i = 0; i < buckets.length(); i++) {
        rank += buckets.get(i);
        if (rank >= targetRank) return i;
    }
    return buckets.length();

    The result is then clamped to [minDeadlineSeconds, maxDeadlineSeconds] and further bounded by Pub/Sub's stream ack deadline range (10–600s), matching MessageDispatcher.computeDeadlineSeconds.

  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  9. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @IntrinsicCandidate() @native()
  10. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @IntrinsicCandidate() @native()
  11. val initialDeadlineSeconds: Int
  12. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  13. val maxAckExtensionPeriodNanos: Long
  14. val maxDeadlineSeconds: Int
  15. val minDeadlineSeconds: Int
  16. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  17. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @IntrinsicCandidate() @native()
  18. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @IntrinsicCandidate() @native()
  19. val percentile: Double
  20. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  21. def toString(): String
    Definition Classes
    AnyRef → Any
  22. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  23. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  24. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

    (Since version 9)

Inherited from AnyRef

Inherited from Any

Ungrouped