[Event Hubs] Introduce timeoutInMs#4239
Conversation
There was a problem hiding this comment.
@ramya-rao-a Specifically anted to clarify if making this change to API is fine. This will subsequently require updates across source, tests and likely samples.
There was a problem hiding this comment.
Lets keep receiver changes out of scope of this PR and re-visit later
|
|
There was a problem hiding this comment.
Did we run the name by @bterlson?
I worry that operationTimeout would make one think that the time applies to the entire operation and not the individual attempts
There was a problem hiding this comment.
Yes, the name 'operationTimeoutInMs' was decided on by Brian and it has always referred to the individual attempt/execution.
Currently though, this PR is scoped per specific changes you wanted in. The documentation/usage of RetryPolicy will need to be made clear and is likely going to have more changes based on further discussions/work we discussed offline for #2835
There was a problem hiding this comment.
@bterlson Given the current context of RetryPolicy related changes/usage in this PR, could you clarify if this needs to change?
There was a problem hiding this comment.
Since we're enforcing a minimum timeout value, I think we should document it here as well.
There was a problem hiding this comment.
But that's only for exponential retry correct? As I see it, that isn't supported yet
There was a problem hiding this comment.
To be fair, I only decided on the suffix! I agree with @ramya-rao-a that operationTimeout is misleading. perAttemptTimeoutInMs? Just timeoutInMs may be appropriate too...
There was a problem hiding this comment.
@chradek was referring to #4239 (comment) when he spoke of the "minimum"
I would go with timeoutInMs for now.
There was a problem hiding this comment.
Can you check if you are using the prettier extension or not? These formatting changes shouldnt be happening
There was a problem hiding this comment.
We had feedback that we should have a minimum value for per operation timeout, else it is easy to abuse the system by forcing frequent timeouts by giving smaller values.
Use the Constants.defaultOperationTimeoutInSeconds as the "minimum" for now
There was a problem hiding this comment.
I see that 4ba2e14 commit has been made in an attempt to address the issue, but the change is not solving the problem at hand.
Use Constants.defaultOperationTimeoutInSeconds as minimum value means that if user provides a value lesser than this, then we ignore user's value and use Constants.defaultOperationTimeoutInSeconds instead
There was a problem hiding this comment.
Lets keep receiver changes out of scope of this PR and re-visit later
c5257d8 to
1d1975e
Compare
There was a problem hiding this comment.
- For readability, pull this code out and have a variable/constant hold the value of the timeout
- Initializing
optionswith{}is done early on, so the checkoptions == undefinedis not needed
There was a problem hiding this comment.
Within the event handler it seemed to require the check, please see updated code
There was a problem hiding this comment.
For readability, pull this code out and have a variable/constant hold the value of the timeout
4ba2e14 to
badb691
Compare
|
@ramya0820 Please avoid force pushing to an open PR, we lose track of all older comments in the Files view |
Co-Authored-By: Ramya Rao <ramya.rao.a@outlook.com>
There was a problem hiding this comment.
Since we're enforcing a minimum timeout value, I think we should document it here as well.
|
|
||
| const operationTimeoutInMs = | ||
| options.retryOptions == undefined || | ||
| options.retryOptions.operationTimeoutInMs == undefined || |
There was a problem hiding this comment.
Maybe a safer check would be
| options.retryOptions.operationTimeoutInMs == undefined || | |
| typeof options.retryOptions.operationTimeoutInMs !== "number" || |
That way we don't allow it to be set to a different type in the last part of your ternary operation. Could also add an isFinite(options.retryOptions.operationTimeoutInMs so we protect against NaN or Infinity (unless we want Infinity as a valid value).
There was a problem hiding this comment.
Nice, we should probably add these validations to other such parameters as well
| } | ||
|
|
||
| const operationTimeoutInMs = | ||
| options.retryOptions == undefined || |
There was a problem hiding this comment.
This logic is duplicated in eventHubReceiver, and will probably be used by the receiver at some point. Could you refactor this into its own function that takes in either retryOptions or operationTimeoutInMs, and then reference this function in both places?
There was a problem hiding this comment.
Finding a place to house a utility like that seemed a bit tricky. Updated/created one along side RetryOptions interface definition in eventHubClient file.
Moreover, this may change and all required validations would likely be done in one place as part of retry module within core-amqp eventually.
| actionAfterTimeout, | ||
| Constants.defaultOperationTimeoutInSeconds * 1000 | ||
| ); | ||
| waitTimer = setTimeout(actionAfterTimeout, getRetryAttemptTimeoutInMs(options!.retryOptions)); |
There was a problem hiding this comment.
Just curious, was the TypeScript compiler unable to tell that options is always defined?
There was a problem hiding this comment.
Yeah, in the IDE I was seeing a squiggly prompt that it may be undefined..
There was a problem hiding this comment.
@chradek Would you prefer options && options.retryOptions over options!.retryOptions.
I am aware of the knee jerk reaction we get when we see the ! :)
Was just curious about what you felt about the above alternative
There was a problem hiding this comment.
I actually wonder if changing
private _trySendBatch(
message: AmqpMessage | Buffer,
tag: any,
options?: SendOptions & EventHubProducerOptions,
format?: number
): Promise<void> {
if (!options) {
options = {};
}
to
private _trySendBatch(
message: AmqpMessage | Buffer,
tag: any,
options: SendOptions & EventHubProducerOptions = {},
format?: number
): Promise<void> {
would solve the squiggles instead since then the compiler should see options always exists.
Edit: Though if that doesn't work, I'd choose the options && options.retryOptions route instead.
There was a problem hiding this comment.
Updating the type had worked
* [Event Hubs] Introduce timeoutInMs on RetryOptions (#4239) * Update event-hubs.api.md file
* [Event Hubs] Introduce timeoutInMs on RetryOptions (#4239) * Update version in constants file
Following is summary of usage of
retryOptionsand instances of applicable operation timeoutsmakeManagementRequestrelies onretryOptionsto support send requests. This already has per try operation timeout implemented incore-amqpand just required us to make option available to users and pass it inreceiveandreceiveBatchoperations already support per try operation timeouts and allow users to configure this value usingmaxWaitTimeInSeconds. However introducingoperationTimeoutInMson retryOptions to mean same thing is bound to get confusing. Should we get rid of this parameter and have users supply this using theretryOptions? @ramya-rao-aFor more context refer to #4171