Skip to content

This repository contains all HTTP client related Utils to be used by all SDKs

License

Notifications You must be signed in to change notification settings

sangeetha5491/aio-lib-core-networking

 
 

Repository files navigation

Version Downloads/week Build Status License Greenkeeper badge Codecov Coverage

Adobe I/O Core Networking Lib

Installing

$ npm install @adobe/aio-lib-core-networking

Usage

  1. Initialize the SDK
const fetchRetry = require('@adobe/aio-lib-core-networking')
  1. Call methods using the initialized SDK
const fetchRetry = require('@adobe/aio-lib-core-networking')
async function sdkTest() {

  return new Promise((resolve, reject) => {
    fetchRetry.exponentialBackoff(url, requestOptions, retryOptions, retryOn, retryDelay)
    .then((response) => {
      if (!response.ok) {
        throw Error(reduceError(response))
      }
      resolve(response.json())
    })
    .catch(err => {
      reject(
        new codes.ERROR_GET_SOMETHING({ sdkDetails, messageValues: err }))
    })
  }) 
}

@adobe/aio-lib-core-networking

Working of HttpExponentialBackoff

image not available

@adobe/aio-lib-core-networking~HttpExponentialBackoff

This class provides methods to implement fetch with retries. The retries use exponential backoff strategy with defaults set to max of 3 retries and initial Delay as 100ms

Kind: inner class of @adobe/aio-lib-core-networking

httpExponentialBackoff.exponentialBackoff(url, requestOptions, retryOptions, retryOn, retryDelay) ⇒ Promise.<Response>

This function will retry connecting to a url end-point, with exponential backoff. Returns a Promise.

Kind: instance method of HttpExponentialBackoff
Returns: Promise.<Response> - Promise object representing the http response

Param Type Description
url string endpoint url
requestOptions object request options which includes the HTTP method, headers, timeout, etc.
retryOptions object retry options with options being maxRetries and initialDelayInMillis
retryOn function | Array Optional Function or Array. If provided, will be used instead of the default
retryDelay function | number Optional Function or number. If provided, will be used instead of the default

Debug Logs

LOG_LEVEL=debug <your_call_here>

Prepend the LOG_LEVEL environment variable and debug value to the call that invokes your function, on the command line. This should output a lot of debug data for your SDK calls.

Contributing

Contributions are welcome! Read the Contributing Guide for more information.

Licensing

This project is licensed under the Apache V2 License. See LICENSE for more information.

About

This repository contains all HTTP client related Utils to be used by all SDKs

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%