feat(xen-api/objects): buffer objects
' events on initial fetch (#3994)
XO requires all objects to be available at the same time.
This commit is contained in:
parent
d866bccf3b
commit
344e9e06d0
@ -983,6 +983,8 @@ export class Xapi extends EventEmitter {
|
|||||||
const types = this._watchedTypes || this._types
|
const types = this._watchedTypes || this._types
|
||||||
|
|
||||||
// initial fetch
|
// initial fetch
|
||||||
|
const flush = this.objects.bufferEvents()
|
||||||
|
try {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
types.map(async type => {
|
types.map(async type => {
|
||||||
try {
|
try {
|
||||||
@ -1002,6 +1004,9 @@ export class Xapi extends EventEmitter {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
} finally {
|
||||||
|
flush()
|
||||||
|
}
|
||||||
this._resolveObjectsFetched()
|
this._resolveObjectsFetched()
|
||||||
|
|
||||||
// event loop
|
// event loop
|
||||||
@ -1060,7 +1065,9 @@ export class Xapi extends EventEmitter {
|
|||||||
// It also has to manually get all objects first.
|
// It also has to manually get all objects first.
|
||||||
_watchEventsLegacy() {
|
_watchEventsLegacy() {
|
||||||
const getAllObjects = async () => {
|
const getAllObjects = async () => {
|
||||||
return Promise.all(
|
const flush = this.objects.bufferEvents()
|
||||||
|
try {
|
||||||
|
await Promise.all(
|
||||||
this._types.map(type =>
|
this._types.map(type =>
|
||||||
this._sessionCall(`${type}.get_all_records`).then(
|
this._sessionCall(`${type}.get_all_records`).then(
|
||||||
objects => {
|
objects => {
|
||||||
@ -1075,7 +1082,11 @@ export class Xapi extends EventEmitter {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
).then(() => this._resolveObjectsFetched())
|
)
|
||||||
|
} finally {
|
||||||
|
flush()
|
||||||
|
}
|
||||||
|
this._resolveObjectsFetched()
|
||||||
}
|
}
|
||||||
|
|
||||||
const watchEvents = () =>
|
const watchEvents = () =>
|
||||||
|
Loading…
Reference in New Issue
Block a user