mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-22 22:59: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'
|
||||
|
||||
const retry = require('p-retry')
|
||||
const defaultProfile = require('./lib/default-profile')
|
||||
|
||||
const retryDefaults = {
|
||||
retries: 3,
|
||||
|
@ -10,7 +11,8 @@ const retryDefaults = {
|
|||
|
||||
const withRetrying = (profile, 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 attempt = () => {
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
'use strict'
|
||||
|
||||
const throttle = require('p-throttle')
|
||||
const defaultProfile = require('./lib/default-profile')
|
||||
|
||||
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 {
|
||||
...profile,
|
||||
|
|
Loading…
Add table
Reference in a new issue