How to use the requestretry.defaults function in requestretry

To help you get started, we’ve selected a few requestretry 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 taskrabbit / elasticsearch-dump / lib / transports / elasticsearch.js View on Github external
retryStrategy: request.RetryStrategies.HTTPOrNetworkError // (default) retry on 5xx or network errors
    }

    if (parent.options[`${options.type}SocksProxy`]) {
      Object.assign(defaultOptions,
        elasticsearch.applyProxy(url, parent.options[`${options.type}SocksProxy`], parent.options[`${options.type}SocksPort`]))
    }

    if (this.parent.options.tlsAuth) {
      Object.assign(defaultOptions,
        this.applySSL([`${options.type}-cert`, `${options.type}-key`, `${options.type}-pass`, `${options.type}-ca`]))

      Object.assign(defaultOptions, this.applySSL(['cert', 'key', 'pass', 'ca']))
    }

    this.baseRequest = request.defaults(defaultOptions)
  }
github hdnpt / geartrack / src / skyTracker.js View on Github external
'use strict';

const sprintf = require('sprintf')
const request = require('requestretry').defaults({ maxAttempts: 2, retryDelay: 1000 })
const parser = require('cheerio')
const utils = require('./utils')
const moment = require('moment-timezone')
const zone = "Asia/Hong_Kong" // +8h

const URL = 'http://www.sky56.cn/track/track/result?tracking_number=%s'

const sky = {}

/**
 * Get Sky56 info
 * Supports PQ... and NL... LVS.. SYB.. ids
 * Async
 *
 * @param id
 * @param callback(Error, SkyInfo)
github acoustic-content-samples / wchtools-cli / authoring-api / lib / utils / utils.js View on Github external
const Q = require("q");
const async = require("async");

const ProductName = "IBM Watson Content Hub";
const ProductAbrev = "wchtools";
const ProductVersion = require("../../package.json").version;
const userAgent = ProductAbrev + "/" + ProductVersion;

const i18nModule = require("i18n-2");
const i18n = getI18N(__dirname, ".json", "en");
const vPath = new RegExp('[?<>*|"]');
const loggers = {};
let httplang;

// Enable the request module cookie jar so cookies can be shared across response, request with this request wrapper
const requestWrapper = require("requestretry").defaults({jar: true});

// Expose the default retry strategy for detecting retryable network errors.
const retryNetworkErrors = require("requestretry").RetryStrategies.NetworkError;

/**
 * Get the object that is used to localize strings.
 *
 * @param directory the directory that the search for the nls directory starts from, it looks up the tree for the nls directory
 * @param extension the extension of the file with localizations. Default to .json if not passed
 * @param defaultLocale the local to use as a default. en is used if not set
 *
 * @returns {Object}
 */
function getI18N (directory, extension, defaultLocale) {
    let dir = directory;
    while (dir && !fs.existsSync(dir + "/nls")) {
github hdnpt / geartrack / src / correosOldTracker.js View on Github external
'use strict';

const request = require('requestretry').defaults({timeout: 10000, maxAttempts: 2, retryDelay: 500})
const parser = require('cheerio')
const utils = require('./utils')
const sprintf = require('sprintf')
const moment = require('moment-timezone')
const zone = "Europe/Madrid" // +1h

const URL = 'https://www.correosexpress.com/web/correosexpress/envios4?param=%s;%s'

const correos = {}

/**
 * Get correos info
 * Scraps the Correos Express website
 * Async
 *
 * Design changes may break this code!!
github hdnpt / geartrack / src / directLink.js View on Github external
'use strict';

const request = require('requestretry').defaults({ maxAttempts: 2, retryDelay: 1000 })
const sprintf = require('sprintf')
const utils = require('./utils')
const moment = require('moment-timezone')
const zone = "Europe/Stockholm" // +2h

const textsURL = 'https://tracking.directlink.com/javascript/timeline_struct.js.php?lang=en'
const URL = 'https://tracking.directlink.com/responseStatus.php?json=1&site_cd={{type}}&lang=en&postal_ref_no={{id}}'

const orderURL = 'https://tracking.directlink.com/multipletrack-client2.php?lang=en&postal_ref_mode=0&order_no={{order}}'

const directURL = 'https://tracking.directlink.com/multipletrack-client2.php?lang=en&postal_ref_mode=1&postal_ref_no='

const directLink = {}

/**
 * Get DirectLink info
github hdnpt / geartrack / src / mrwTracker.js View on Github external
'use strict';

const request = require('requestretry').defaults({timeout: 5000, maxAttempts: 2, retryDelay: 500})
const parser = require('cheerio')
const utils = require('./utils')
const sprintf = require('sprintf')
const moment = require('moment-timezone')
const zone = "Europe/Madrid" // +1h

const URL = 'http://www.mrw.pt/seguimiento_envios/MRW_historico_nacional.asp?enviament='

const tracker = {}

/**
 * Get MRW info
 *
 * @param id
 * @param cb(Error, EntityInfo)
 */
github gbif / portal16 / app / helpers / request / requestAgents.js View on Github external
maxAttempts: 1,
  retryDelay: 3000, // in milliseconds
  retryStrategy: request.RetryStrategies.HTTPOrNetworkError, // (default) retry on 5xx or network errors
  timeout: 45000 // in milliseconds
});


// seperate pool for species requests as that API often has outages.
const speciesAgent = new Agent({
  maxSockets: 8000, // Default = Infinity
  maxFreeSockets: 256, // default
  keepAlive: true,
  keepAliveMsecs: 1000
});

let speciesRequest = request.defaults({
  agent: speciesAgent,
  headers: {
    'User-Agent': 'GBIF-portal Occurrence'
  },
  maxAttempts: 1,
  retryDelay: 3000, // in milliseconds
  retryStrategy: request.RetryStrategies.HTTPOrNetworkError, // (default) retry on 5xx or network errors
  timeout: 45000 // in milliseconds
});

module.exports = {
    standard: stdRequest,
    occurrence: occurrenceRequest,
    species: speciesRequest
};
github hdnpt / geartrack / src / adicionalTracker.js View on Github external
'use strict';

const request = require('requestretry').defaults({timeout: 10000, maxAttempts: 1, retryDelay: 500})
const sprintf = require('sprintf')
const utils = require('./utils')
const moment = require('moment-timezone')
const zone = "Europe/Lisbon"

const URL = 'http://www.adicional.pt/contact/tracking.php?reference=%s&cp=%s'

const adicional = {}

/**
 * Get Adicional info
 * Async
 *
 * @param id
 * @param postcode
 * @param callback(Error, AdicionalInfo)

requestretry

request-retry wrap nodejs request to retry http(s) requests in case of error

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis

Similar packages