mirror of
https://github.com/mclueppers/xo-server.git
synced 2025-07-28 08:24:28 +02:00
Handles object deletions in XAPI events.
This commit is contained in:
parent
95a4dc94a4
commit
302d9cb321
27
src/xo.js
27
src/xo.js
@ -321,18 +321,27 @@ Xo.prototype.start = function (cfg) {
|
|||||||
return function loop() {
|
return function loop() {
|
||||||
return xapi.call('event.next').then(function (events) {
|
return xapi.call('event.next').then(function (events) {
|
||||||
_.each(events, function (event) {
|
_.each(events, function (event) {
|
||||||
var collection = xobjs[xclasses_map[event.class]];
|
var klass = event.class;
|
||||||
|
var collection = xobjs[xclasses_map[klass]];
|
||||||
if (collection)
|
if (collection)
|
||||||
{
|
{
|
||||||
var record = event.snapshot;
|
var operation = event.operation;
|
||||||
record.id = event.ref;
|
var ref = event.ref;
|
||||||
record.pool = pool_id;
|
|
||||||
|
|
||||||
console.log(xapi.host, event.class, event.ref);
|
console.log(xapi.host, operation, klass, ref);
|
||||||
|
|
||||||
// @todo Handle operation types.
|
if ('del' === event.operation)
|
||||||
collection.add(event.snapshot, {'replace': true});
|
{
|
||||||
|
collection.remove(event.ref);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var record = event.snapshot;
|
||||||
|
record.id = ref;
|
||||||
|
record.pool = pool_id;
|
||||||
|
|
||||||
|
collection.add(record, {'replace': true});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -364,7 +373,9 @@ Xo.prototype.start = function (cfg) {
|
|||||||
_.each(servers, connect);
|
_.each(servers, connect);
|
||||||
});
|
});
|
||||||
xo.servers.on('remove', function (server_ids) {
|
xo.servers.on('remove', function (server_ids) {
|
||||||
// @todo
|
_.each(server_ids, function (server_id) {
|
||||||
|
delete xo.connections[server_id];
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// xo events are used to automatically close connections if the
|
// xo events are used to automatically close connections if the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user