-
Notifications
You must be signed in to change notification settings - Fork 585
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(util-waiter): expose minDelay and maxDelay for waiters (#1839)
* fix: expose min delay and max to the client as optional on waiterconfiguration * fix: validation error should reference exported WaiterConfiguration type * fix: minor update to min/max delay description wording * fix: added additional clarifying language * fix: clarify comments around minDelay and maxDelay * fix: waiter validation throws a proper error object
- Loading branch information
1 parent
314d3b3
commit 25cb359
Showing
6 changed files
with
64 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,23 @@ | ||
import { ResolvedWaiterOptions } from "../waiter"; | ||
import { WaiterOptions } from "../waiter"; | ||
|
||
/** | ||
* Validates that waiter options are passed correctly | ||
* @param options a waiter configuration object | ||
*/ | ||
export const validateWaiterOptions = <Client>(options: ResolvedWaiterOptions<Client>): void => { | ||
export const validateWaiterOptions = <Client>(options: WaiterOptions<Client>): void => { | ||
if (options.maxWaitTime < 1) { | ||
throw `WaiterOptions.maxWaitTime must be greater than 0`; | ||
throw new Error(`WaiterConfiguration.maxWaitTime must be greater than 0`); | ||
} else if (options.minDelay < 1) { | ||
throw new Error(`WaiterConfiguration.minDelay must be greater than 0`); | ||
} else if (options.maxDelay < 1) { | ||
throw new Error(`WaiterConfiguration.maxDelay must be greater than 0`); | ||
} else if (options.maxWaitTime <= options.minDelay) { | ||
throw `WaiterOptions.maxWaitTime [${options.maxWaitTime}] must be greater than WaiterOptions.minDelay [${options.minDelay}] for this waiter`; | ||
throw new Error( | ||
`WaiterConfiguration.maxWaitTime [${options.maxWaitTime}] must be greater than WaiterConfiguration.minDelay [${options.minDelay}] for this waiter` | ||
); | ||
} else if (options.maxDelay < options.minDelay) { | ||
throw new Error( | ||
`WaiterConfiguration.maxDelay [${options.maxDelay}] must be greater than WaiterConfiguration.minDelay [${options.minDelay}] for this waiter` | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters