@@ -560,6 +560,8 @@ export class Message implements tracing.MessageWithAttributes {
560560 * ever have, while it's under library control.
561561 * @property {Duration } [maxAckDeadline] The maximum time that ackDeadline should
562562 * ever have, while it's under library control.
563+ * @property {Duration } [maxExtensionTime] The maximum time that ackDeadline should
564+ * ever have, while it's under library control.
563565 * @property {BatchOptions } [batching] Request batching options; this is for
564566 * batching acks and modacks being sent back to the server.
565567 * @property {FlowControlOptions } [flowControl] Flow control options.
@@ -569,11 +571,9 @@ export class Message implements tracing.MessageWithAttributes {
569571 * @property {MessageStreamOptions } [streamingOptions] Streaming options.
570572 */
571573export interface SubscriberOptions {
572- /** @deprecated Use minAckDeadline and maxAckDeadline. */
573- ackDeadline ?: number ;
574-
575574 minAckDeadline ?: Duration ;
576575 maxAckDeadline ?: Duration ;
576+ maxExtensionTime ?: Duration ;
577577 batching ?: BatchOptions ;
578578 flowControl ?: FlowControlOptions ;
579579 useLegacyFlowControl ?: boolean ;
@@ -597,6 +597,7 @@ export class Subscriber extends EventEmitter {
597597 maxBytes : number ;
598598 useLegacyFlowControl : boolean ;
599599 isOpen : boolean ;
600+ maxExtensionTime : Duration ;
600601 private _acks ! : AckQueue ;
601602 private _histogram : Histogram ;
602603 private _inventory ! : LeaseManager ;
@@ -612,9 +613,11 @@ export class Subscriber extends EventEmitter {
612613 constructor ( subscription : Subscription , options = { } ) {
613614 super ( ) ;
614615
615- this . ackDeadline = defaultOptions . subscription . ackDeadline ;
616+ this . ackDeadline =
617+ defaultOptions . subscription . startingAckDeadline . totalOf ( 'second' ) ;
616618 this . maxMessages = defaultOptions . subscription . maxOutstandingMessages ;
617619 this . maxBytes = defaultOptions . subscription . maxOutstandingBytes ;
620+ this . maxExtensionTime = defaultOptions . subscription . maxExtensionTime ;
618621 this . useLegacyFlowControl = false ;
619622 this . isOpen = false ;
620623 this . _histogram = new Histogram ( { min : 10 , max : 600 } ) ;
@@ -960,15 +963,6 @@ export class Subscriber extends EventEmitter {
960963 setOptions ( options : SubscriberOptions ) : void {
961964 this . _options = options ;
962965
963- // The user-set ackDeadline value basically pegs the extension time.
964- // We'll emulate it by overwriting min/max.
965- const passedAckDeadline = options . ackDeadline ;
966- if ( passedAckDeadline !== undefined ) {
967- this . ackDeadline = passedAckDeadline ;
968- options . minAckDeadline = Duration . from ( { seconds : passedAckDeadline } ) ;
969- options . maxAckDeadline = Duration . from ( { seconds : passedAckDeadline } ) ;
970- }
971-
972966 this . useLegacyFlowControl = options . useLegacyFlowControl || false ;
973967 if ( options . flowControl ) {
974968 this . maxMessages =
@@ -998,6 +992,18 @@ export class Subscriber extends EventEmitter {
998992 if ( this . _inventory ) {
999993 this . _inventory . setOptions ( this . _options . flowControl ! ) ;
1000994 }
995+
996+ this . updateAckDeadline ( ) ;
997+ }
998+
999+ /**
1000+ * Retrieves our effective options. This is mostly for unit test use.
1001+ *
1002+ * @private
1003+ * @returns {SubscriberOptions } The options.
1004+ */
1005+ getOptions ( ) : SubscriberOptions {
1006+ return this . _options ;
10011007 }
10021008
10031009 /**
0 commit comments