How to use the @f5devcentral/f5-cloud-libs.util.tryUntil function in @f5devcentral/f5-cloud-libs

To help you get started, we’ve selected a few @f5devcentral/f5-cloud-libs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github F5Networks / f5-declarative-onboarding / src / nodejs / restWorker.js View on Github external
.setReferer(incomingRestOp.getUri().href);

    const retryFunc = () => this.restRequestSender.sendGet(restOperation)
        .then((response) => {
            const body = response.getBody();
            if (body.status === 'FAILED' || body.status === 'FINISHED') {
                return Promise.resolve(body);
            }
            return Promise.reject();
        })
        .catch(() => Promise.reject());

    // retry interval:
    //   - this.retryInterval for testing
    //   - we want to poll for more than 30 minutes because that is the TCW -> DO timeout so DO should be longer
    return cloudUtil.tryUntil(
        this,
        { retryIntervalMs: this.retryInterval || 5000, maxRetries: 384 },
        retryFunc
    )
        .then((response) => {
            switch (response.status) {
            case 'FINISHED':
                this.state.doState.updateResult(taskId, 200, STATUS.STATUS_OK, 'success');
                break;
            case 'FAILED':
                this.state.doState.updateResult(
                    taskId,
                    422,
                    STATUS.STATUS_ERROR,
                    'failed',
                    response.errorMessage
github F5Networks / f5-declarative-onboarding / src / nodejs / restWorker.js View on Github external
return new Promise((resolve, reject) => {
        const retryOptions = {};
        Object.assign(retryOptions, cloudUtil.QUICK_BUT_LONG_RETRY);
        retryOptions.continueOnError = true;

        cloudUtil.tryUntil(this, retryOptions, retryFunc)
            .then(() => {
                resolve();
            })
            .catch((err) => {
                logger.warning(`Error saving state: ${err}`);
                reject(err);
            });
    });
}