Live Query basic monitoring (#4168)

* Adds uuid based client identification to prevent overflows

* no-super

* Adds cloud code monitoring

* fixes test

* nit
This commit is contained in:
Florent Vilmart
2017-09-15 17:20:51 -04:00
committed by GitHub
parent 7ecb36e71e
commit d0184f438d
5 changed files with 90 additions and 16 deletions

View File

@@ -15,6 +15,7 @@ const baseStore = function() {
const Validators = {};
const Functions = {};
const Jobs = {};
const LiveQuery = [];
const Triggers = Object.keys(Types).reduce(function(base, key){
base[key] = {};
return base;
@@ -24,7 +25,8 @@ const baseStore = function() {
Functions,
Jobs,
Validators,
Triggers
Triggers,
LiveQuery,
});
};
@@ -49,6 +51,12 @@ export function addTrigger(type, className, handler, applicationId) {
_triggerStore[applicationId].Triggers[type][className] = handler;
}
export function addLiveQueryEventHandler(handler, applicationId) {
applicationId = applicationId || Parse.applicationId;
_triggerStore[applicationId] = _triggerStore[applicationId] || baseStore();
_triggerStore[applicationId].LiveQuery.push(handler);
}
export function removeFunction(functionName, applicationId) {
applicationId = applicationId || Parse.applicationId;
delete _triggerStore[applicationId].Functions[functionName]
@@ -411,3 +419,8 @@ export function inflate(data, restObject) {
}
return Parse.Object.fromJSON(copy);
}
export function runLiveQueryEventHandlers(data, applicationId = Parse.applicationId) {
if (!_triggerStore || !_triggerStore[applicationId] || !_triggerStore[applicationId].LiveQuery) { return; }
_triggerStore[applicationId].LiveQuery.forEach((handler) => handler(data));
}