Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
260b0e6
[Event Hubs] Introduce timeoutInMs on RetryOptions (#4239)
ramya0820 Jul 11, 2019
c74f5e4
Merge branch 'master' of https://github.com/ramya0820/azure-sdk-for-js
Jul 13, 2019
00016cb
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-js
Jul 15, 2019
5c12c13
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-js
Jul 16, 2019
2081256
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-js
Jul 17, 2019
f3511e0
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-js
Jul 19, 2019
ee0994f
Update retryOptions
Jul 23, 2019
f5cf034
Update constructor
Jul 23, 2019
340c8bd
Update types
Jul 23, 2019
558f67e
Minor errors
Jul 23, 2019
6131e97
Include api.md file
Jul 23, 2019
8acb8ea
Use timeOutInMs
Jul 23, 2019
0263f0c
Merge branch 'issue-4266' of https://github.com/ramya0820/azure-sdk-f…
Jul 23, 2019
c6e5d02
Fix typo
Jul 23, 2019
251b26c
Merge branch 'master' into issue-4266
ramya0820 Jul 23, 2019
d51b4c6
Remove comma
Jul 25, 2019
11b8c38
Merge branch 'issue-4266' of https://github.com/ramya0820/azure-sdk-f…
Jul 25, 2019
a5a2f3d
Address comments
Jul 26, 2019
91c5bc3
Add comment
Jul 26, 2019
ea840e3
Remove _initRetryOptions
Jul 29, 2019
6a05bad
Fix import
Jul 29, 2019
94a58e1
Simplify getOwnerLevel check
Jul 29, 2019
4a25bd9
Simplify retryOptions handling in sender
Jul 29, 2019
c2bf51a
Update retryInterval -> delayInMs
Jul 29, 2019
09d5d42
Add api.md file
Jul 29, 2019
9a9c5f8
Update management requests to include exponential retry related options
Jul 29, 2019
2d6c112
Revert rename
Jul 29, 2019
aa495cd
Update retryInterval checks
Jul 29, 2019
1b8c7cb
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-js in…
Jul 29, 2019
d623472
Add api.md file
Jul 29, 2019
fdf729a
Uniformize usage
Jul 30, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sdk/eventhub/event-hubs/review/event-hubs.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { EventHubConnectionConfig } from '@azure/core-amqp';
import { MessagingError } from '@azure/core-amqp';
import { Receiver } from 'rhea-promise';
import { ReceiverOptions } from 'rhea-promise';
import { RetryPolicy } from '@azure/core-amqp';
import { Sender } from 'rhea-promise';
import { SharedKeyCredential } from '@azure/core-amqp';
import { TokenCredential } from '@azure/core-amqp';
Expand Down Expand Up @@ -190,8 +191,11 @@ export class ReceiveHandler {

// @public
export interface RetryOptions {
maxExponentialRetryDelayInMs?: number;
maxRetries?: number;
minExponentialRetryDelayInMs?: number;
retryInterval?: number;
retryPolicy?: RetryPolicy;
timeoutInMs?: number;
}

Expand Down
27 changes: 16 additions & 11 deletions sdk/eventhub/event-hubs/src/eventHubClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
SharedKeyCredential,
ConnectionConfig,
isTokenCredential,
Constants
Constants,
RetryPolicy
} from "@azure/core-amqp";

import { ConnectionContext } from "./connectionContext";
Expand Down Expand Up @@ -40,16 +41,20 @@ export interface RetryOptions {
* A minimum value of 60 seconds will be used if a value not greater than this is provided.
*/
timeoutInMs?: number;
// /**
// * The maximum value the `retryInterval` gets incremented exponentially between retries.
// * Not applicable, when `isExponential` is set to `false`.
// */
// maxRetryInterval?: number;
// /**
// * Boolean denoting if the `retryInterval` should be incremented exponentially between
// * retries or kept the same.
// */
// isExponential?: boolean;
/**
* @property {RetryPolicy} [retryPolicy] Denotes which retry policy to apply. If undefined, defaults to `LinearRetryPolicy`
*/
retryPolicy?: RetryPolicy;
/**
* @property {number} [maxExponentialRetryDelayInMs] Denotes the maximum delay between retries
* that the retry attempts will be capped at. Applicable only when performing exponential retry.
*/
maxExponentialRetryDelayInMs?: number;
/**
* @property {number} [minExponentialRetryDelayInMs] Denotes the minimum delay between retries
* to use. Applicable only when performing exponential retry.
*/
minExponentialRetryDelayInMs?: number;
}

export function getRetryAttemptTimeoutInMs(retryOptions: RetryOptions | undefined): number {
Expand Down
7 changes: 6 additions & 1 deletion sdk/eventhub/event-hubs/src/eventHubSender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,12 @@ export class EventHubSender extends LinkEntity {
connectionId: this._context.connectionId,
operationType: RetryOperationType.sendMessage,
maxRetries: maxRetries,
delayInSeconds: delayInSeconds
delayInSeconds: delayInSeconds,
retryPolicy: options.retryOptions && options.retryOptions.retryPolicy,
minExponentialRetryDelayInMs:
options.retryOptions && options.retryOptions.minExponentialRetryDelayInMs,
maxExponentialRetryDelayInMs:
options.retryOptions && options.retryOptions.maxExponentialRetryDelayInMs
};
return retry<void>(config);
}
Expand Down
34 changes: 28 additions & 6 deletions sdk/eventhub/event-hubs/src/receiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
Constants,
RetryOperationType,
retry,
MessagingError
MessagingError,
RetryPolicy
} from "@azure/core-amqp";
import { ReceiveHandler } from "./receiveHandler";
import { AbortSignalLike, AbortError } from "@azure/abort-controller";
Expand Down Expand Up @@ -73,7 +74,10 @@ export class EventHubConsumer {
/**
* @property The set of retry options to configure the receiveBatch operation.
*/
private _retryOptions: Required<Pick<RetryOptions, "maxRetries" | "retryInterval">>;
private _retryOptions: Required<
Pick<RetryOptions, "maxRetries" | "retryInterval" | "retryPolicy">
> &
RetryOptions;

/**
* @property Returns `true` if the consumer is closed. This can happen either because the consumer
Expand Down Expand Up @@ -370,7 +374,7 @@ export class EventHubConsumer {
);

const addTimeout = (): void => {
let msg = "[%s] Setting the wait timer for %d seconds for receiver '%s'.";
const msg = "[%s] Setting the wait timer for %d seconds for receiver '%s'.";
Comment thread
ramya-rao-a marked this conversation as resolved.
log.batching(
msg,
this._context.connectionId,
Expand Down Expand Up @@ -407,7 +411,10 @@ export class EventHubConsumer {
delayInSeconds: retryOptions.retryInterval,
operation: retrieveEvents,
operationType: RetryOperationType.receiveMessage,
maxRetries: retryOptions.maxRetries
maxRetries: retryOptions.maxRetries,
retryPolicy: retryOptions.retryPolicy,
minExponentialRetryDelayInMs: retryOptions.minExponentialRetryDelayInMs,
maxExponentialRetryDelayInMs: retryOptions.maxExponentialRetryDelayInMs
};
return retry<ReceivedEventData[]>(config);
}
Expand Down Expand Up @@ -436,9 +443,13 @@ export class EventHubConsumer {
}
}

/**
*
* @param retryOptions Sets default values for retryOptions if it exists.
*/
private _initRetryOptions(
retryOptions: RetryOptions = {}
): Required<Pick<RetryOptions, "maxRetries" | "retryInterval">> {
): Required<Pick<RetryOptions, "maxRetries" | "retryInterval" | "retryPolicy">> & RetryOptions {
const maxRetries =
typeof retryOptions.maxRetries === "number"
? retryOptions.maxRetries
Expand All @@ -447,10 +458,21 @@ export class EventHubConsumer {
typeof retryOptions.retryInterval === "number" && retryOptions.retryInterval > 0
? retryOptions.retryInterval / 1000
: Constants.defaultDelayBetweenOperationRetriesInSeconds;
const retryPolicy = retryOptions.retryPolicy
? retryOptions.retryPolicy
: RetryPolicy.LinearRetryPolicy;

const timeoutInMs = retryOptions.timeoutInMs;
const minExponentialRetryDelayInMs = retryOptions.minExponentialRetryDelayInMs;
Comment thread
ramya-rao-a marked this conversation as resolved.
Outdated
const maxExponentialRetryDelayInMs = retryOptions.maxExponentialRetryDelayInMs;

return {
maxRetries,
retryInterval
retryInterval,
timeoutInMs,
retryPolicy,
minExponentialRetryDelayInMs,
maxExponentialRetryDelayInMs
};
}

Expand Down