org.apache.pekko.stream.connectors.googlecloud.pubsub.grpc
AckDeadlineDistribution
Companion object AckDeadlineDistribution
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
- Alphabetic
- By Inheritance
- AckDeadlineDistribution
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
- 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
initialDeadlineSecondsif 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), matchingMessageDispatcher.computeDeadlineSeconds. - final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- val initialDeadlineSeconds: Int
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- val maxAckExtensionPeriodNanos: Long
- val maxDeadlineSeconds: Int
- val minDeadlineSeconds: Int
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- val percentile: Double
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])