Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@convoyr/plugin-retry

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@convoyr/plugin-retry

> A retry plugin for [Convoyr](https://github.com/jscutlery/convoyr).

  • 4.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
2
Weekly downloads
 
Created
Source

@convoyr/plugin-retry

A retry plugin for Convoyr.

This plugin retries failed network requests using a configurable back-off strategy.

Requirements

The plugin requires @convoyr/core and @convoyr/angular to be installed.

Installation

yarn add @convoyr/plugin-retry

or

npm install @convoyr/plugin-retry

Usage

The whole configuration object is optional.

import { ConvoyrModule } from '@convoyr/angular';
import { createRetryPlugin } from '@convoyr/plugin-retry';

@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule,
    HttpClientModule,
    ConvoyrModule.forRoot({
      plugins: [createRetryPlugin()],
    }),
  ],
  bootstrap: [AppComponent],
})
export class AppModule {}

Available options

You can give a partial configuration object it will be merged with default values.

PropertyTypeDefault valueDescription
initialIntervalMsnumber300Duration before the first retry.
maxIntervalMsnumber10_000Maximum time span before retrying.
maxRetriesnumber3Maximum number of retries.
shouldRetryRetryPredicateisServerOrUnknownErrorPredicate function to know which failed request should be retried.
shouldHandleRequestRequestCondition() => truePredicate function to know which request the plugin should handle.

Here is an example passing a configuration object.

Keep in mind that HTTP error is not emitted while the plugin is retrying. In the following example the HTTP error will be emitted after 10 retries, then the observable completes.

import { MemoryStorage } from '@convoyr/plugin-cache';

@NgModule({
  imports: [
    ConvoyrModule.forRoot({
      plugins: [
        createRetryPlugin({
          initialIntervalMs: 500,
          maxIntervalMs: 20_000,
          maxRetries: 10,
          shouldRetry: (response) => response.status !== 404,
          shouldHandleRequest: ({ request }) =>
            request.url.includes('api.github.com'),
        }),
      ],
    }),
  ],
})
export class AppModule {}

FAQs

Package last updated on 30 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc