Skip to content

Commit

Permalink
feat(xen-api): limit concurrent calls to 20
Browse files Browse the repository at this point in the history
Fixes xoa-support#3767

Can be changed via `callConcurrency` option.
  • Loading branch information
julien-f committed Jun 14, 2021
1 parent dafa4ce commit 51f0138
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- [IPs] Handle space-delimited IP address format provided by outdated guest tools [5801](https://github.com/vatesfr/xen-orchestra/issues/5801) (PR [5805](https://github.com/vatesfr/xen-orchestra/pull/5805))
- [API/pool.listPoolsMatchingCriteria] fix `unknown error from the peer` error (PR [5807](https://github.com/vatesfr/xen-orchestra/pull/5807))
- [Backup] Limit number of connections to hosts, which should reduce the occurences of `ECONNRESET`

### Packages to release

Expand Down
1 change: 1 addition & 0 deletions packages/xen-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"jest-diff": "^26.4.2",
"json-rpc-protocol": "^0.13.1",
"kindof": "^2.0.0",
"limit-concurrency-decorator": "^0.5.0",
"lodash": "^4.17.4",
"make-error": "^1.3.0",
"minimist": "^1.2.0",
Expand Down
3 changes: 3 additions & 0 deletions packages/xen-api/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Collection } from 'xo-collection'
import { EventEmitter } from 'events'
import { map, noop, omit } from 'lodash'
import { cancelable, defer, fromCallback, fromEvents, ignoreErrors, pDelay, pRetry, pTimeout } from 'promise-toolbox'
import { limitConcurrency } from 'limit-concurrency-decorator'

import autoTransport from './transports/auto'
import coalesceCalls from './_coalesceCalls'
Expand Down Expand Up @@ -88,6 +89,8 @@ export class Xapi extends EventEmitter {
this._RecordsByType = { __proto__: null }
this._reverseHostIpAddresses = opts.reverseHostIpAddresses ?? false

this._call = limitConcurrency(opts.callConcurrency ?? 20)(this._call)

this._roCallRetryOptions = {
delay: 1e3,
tries: 10,
Expand Down

0 comments on commit 51f0138

Please sign in to comment.