function lookupdRequest (url, callback) {
  // All responses are JSON
  const options = {
    url,
    method: 'GET',
    json: true,
    timeout: 2000
  }

  const requestWithRetry = cb => request(options, cb)
  const retryOptions = { times: 3, interval: 500 }

  async.retry(retryOptions, requestWithRetry, (err, response, data = {}) => {
    if (err) {
      log(`lookup failed for ${url}`)
      return callback(null, [])
    }

    const statusCode = (data ? data.status_code : null) || response.statusCode
    if (statusCode !== 200) {
      log(`lookup failed for ${url}. Returned status code: ${statusCode}.`)
      return callback(null, [])
    }

    try {
      let { producers } = data

      // Support pre version 1.x lookupd response.
      if (!_.isEmpty(data.data)) {
        producers = data.data.producers
      }

      callback(null, producers)
    } catch (err) {
      log(`lookup failed. Getting unsupported JSON back!`)
      callback(null, [])
    }
  })
}
/**
 * lookupdRequest returns the list of producers from a lookupd given a
 * URL to query.
 *
 * The callback will not return an error since it's assumed that there might
 * be transient issues with lookupds.
 *
 * @param {String} url
 * @param {Function} callback
 */
lookupdRequest returns the list of producers from a lookupd given a
URL to query.

The callback will not return an error since it's assumed that there might
be transient issues with lookupds.

@param {String} url
@param {Function} callback
lookupdRequest returns the list of producers from a lookupd given a URL to query . The callback will not return an error since it ' s assumed that there might be transient issues with lookupds . @param { String } url @param { Function } callback
function lookupdRequest (url, callback) {
  const options = {
    url,
    method: 'GET',
    json: true,
    timeout: 2000
  }
  const requestWithRetry = cb => request(options, cb)
  const retryOptions = { times: 3, interval: 500 }
  async.retry(retryOptions, requestWithRetry, (err, response, data = {}) => {
    if (err) {
      log(`lookup failed for ${url}`)
      return callback(null, [])
    }
    const statusCode = (data ? data.status_code : null) || response.statusCode
    if (statusCode !== 200) {
      log(`lookup failed for ${url}. Returned status code: ${statusCode}.`)
      return callback(null, [])
    }
    try {
      let { producers } = data
      if (!_.isEmpty(data.data)) {
        producers = data.data.producers
      }
      callback(null, producers)
    } catch (err) {
      log(`lookup failed. Getting unsupported JSON back!`)
      callback(null, [])
    }
  })
}
function lookupdRequest ( url , callback ) { const options = { url , method : 'GET' , json : true , timeout : 2000 } const requestWithRetry = cb => request ( options , cb ) const retryOptions = { times : 3 , interval : 500 } async . retry ( retryOptions , requestWithRetry , ( err , response , data = { } ) => { if ( err ) { log ( ` ${ url } ` ) return callback ( null , [ ] ) } const statusCode = ( data ? data . status_code : null ) || response . statusCode if ( statusCode !== 200 ) { log ( ` ${ url } ${ statusCode } ` ) return callback ( null , [ ] ) } try { let { producers } = data if ( ! _ . isEmpty ( data . data ) ) { producers = data . data . producers } callback ( null , producers ) } catch ( err ) { log ( ` ` ) callback ( null , [ ] ) } } ) }
lookupdRequest returns the list of producers from a lookupd given a
 URL to query.
lookupdRequest returns the list of producers from a lookupd given a URL to query .
// All responses are JSON // Support pre version 1.x lookupd response.