mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
throttle & retry: use default profile 🐛
This commit is contained in:
parent
42b2a8a7bf
commit
51b1e68ddd
2 changed files with 6 additions and 2 deletions
4
retry.js
4
retry.js
|
@ -1,6 +1,7 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const retry = require('p-retry')
|
const retry = require('p-retry')
|
||||||
|
const defaultProfile = require('./lib/default-profile')
|
||||||
|
|
||||||
const retryDefaults = {
|
const retryDefaults = {
|
||||||
retries: 3,
|
retries: 3,
|
||||||
|
@ -10,7 +11,8 @@ const retryDefaults = {
|
||||||
|
|
||||||
const withRetrying = (profile, retryOpts = {}) => {
|
const withRetrying = (profile, retryOpts = {}) => {
|
||||||
retryOpts = Object.assign({}, retryDefaults, retryOpts)
|
retryOpts = Object.assign({}, retryDefaults, retryOpts)
|
||||||
const {request} = profile
|
// https://github.com/public-transport/hafas-client/issues/76#issuecomment-574408717
|
||||||
|
const {request} = {...defaultProfile, ...profile}
|
||||||
|
|
||||||
const retryingRequest = (...args) => {
|
const retryingRequest = (...args) => {
|
||||||
const attempt = () => {
|
const attempt = () => {
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const throttle = require('p-throttle')
|
const throttle = require('p-throttle')
|
||||||
|
const defaultProfile = require('./lib/default-profile')
|
||||||
|
|
||||||
const withThrottling = (profile, limit = 5, interval = 1000) => {
|
const withThrottling = (profile, limit = 5, interval = 1000) => {
|
||||||
const {request} = profile
|
// https://github.com/public-transport/hafas-client/issues/76#issuecomment-574408717
|
||||||
|
const {request} = {...defaultProfile, ...profile}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...profile,
|
...profile,
|
||||||
|
|
Loading…
Add table
Reference in a new issue