chore(xen-api): _addObject → _addRecordToCache, _removeObject → _removeRecordFromCache

This commit is contained in:
Julien Fontanet 2019-03-28 16:17:53 +01:00
parent a73306817b
commit fe1da4ea12

View File

@ -755,7 +755,7 @@ export class Xapi extends EventEmitter {
} }
} }
_addObject(type, ref, object) { _addRecordToCache(type, ref, object) {
object = this._wrapRecord(type, ref, object) object = this._wrapRecord(type, ref, object)
// Finally freezes the object. // Finally freezes the object.
@ -811,14 +811,14 @@ export class Xapi extends EventEmitter {
} }
const { ref } = event const { ref } = event
if (event.operation === 'del') { if (event.operation === 'del') {
this._removeObject(type, ref) this._removeRecordFromCache(type, ref)
} else { } else {
this._addObject(type, ref, event.snapshot) this._addRecordToCache(type, ref, event.snapshot)
} }
}) })
} }
_removeObject(type, ref) { _removeRecordFromCache(type, ref) {
const byRefs = this._objectsByRef const byRefs = this._objectsByRef
const object = byRefs[ref] const object = byRefs[ref]
if (object !== undefined) { if (object !== undefined) {
@ -888,7 +888,7 @@ export class Xapi extends EventEmitter {
(record, ref) => { (record, ref) => {
// we can bypass _processEvents here because they are all *add* // we can bypass _processEvents here because they are all *add*
// event and all objects are of the same type // event and all objects are of the same type
this._addObject(type, ref, record) this._addRecordToCache(type, ref, record)
} }
) )
} catch (error) { } catch (error) {
@ -948,10 +948,10 @@ export class Xapi extends EventEmitter {
}) })
forOwn(tasks, (task, ref) => { forOwn(tasks, (task, ref) => {
toRemove.delete(ref) toRemove.delete(ref)
this._addObject('task', ref, task) this._addRecordToCache('task', ref, task)
}) })
toRemove.forEach(ref => { toRemove.forEach(ref => {
this._removeObject('task', ref) this._removeRecordFromCache('task', ref)
}) })
}) })
) )
@ -972,7 +972,7 @@ export class Xapi extends EventEmitter {
this._sessionCall(`${type}.get_all_records`).then( this._sessionCall(`${type}.get_all_records`).then(
objects => { objects => {
forEach(objects, (object, ref) => { forEach(objects, (object, ref) => {
this._addObject(type, ref, object) this._addRecordToCache(type, ref, object)
}) })
}, },
error => { error => {