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
|
||||
|
||||
// initial fetch
|
||||
const flush = this.objects.bufferEvents()
|
||||
try {
|
||||
await Promise.all(
|
||||
types.map(async type => {
|
||||
try {
|
||||
@ -1002,6 +1004,9 @@ export class Xapi extends EventEmitter {
|
||||
}
|
||||
})
|
||||
)
|
||||
} finally {
|
||||
flush()
|
||||
}
|
||||
this._resolveObjectsFetched()
|
||||
|
||||
// event loop
|
||||
@ -1060,7 +1065,9 @@ export class Xapi extends EventEmitter {
|
||||
// It also has to manually get all objects first.
|
||||
_watchEventsLegacy() {
|
||||
const getAllObjects = async () => {
|
||||
return Promise.all(
|
||||
const flush = this.objects.bufferEvents()
|
||||
try {
|
||||
await Promise.all(
|
||||
this._types.map(type =>
|
||||
this._sessionCall(`${type}.get_all_records`).then(
|
||||
objects => {
|
||||
@ -1075,7 +1082,11 @@ export class Xapi extends EventEmitter {
|
||||
}
|
||||
)
|
||||
)
|
||||
).then(() => this._resolveObjectsFetched())
|
||||
)
|
||||
} finally {
|
||||
flush()
|
||||
}
|
||||
this._resolveObjectsFetched()
|
||||
}
|
||||
|
||||
const watchEvents = () =>
|
||||
|
Loading…
Reference in New Issue
Block a user