feat(maintenance): add realtime usage stats
This commit is contained in:
parent
8102b4f908
commit
554d3c3557
|
@ -69,6 +69,7 @@ const DELETE_TYPE_EXECUTIONS = 'executions';
|
||||||
const DELETE_TYPE_AUDIT = 'audit';
|
const DELETE_TYPE_AUDIT = 'audit';
|
||||||
const DELETE_TYPE_ABUSE = 'abuse';
|
const DELETE_TYPE_ABUSE = 'abuse';
|
||||||
const DELETE_TYPE_CERTIFICATES = 'certificates';
|
const DELETE_TYPE_CERTIFICATES = 'certificates';
|
||||||
|
const DELETE_TYPE_REALTIME = 'realtime';
|
||||||
// Auth Types
|
// Auth Types
|
||||||
const APP_AUTH_TYPE_SESSION = 'Session';
|
const APP_AUTH_TYPE_SESSION = 'Session';
|
||||||
const APP_AUTH_TYPE_JWT = 'JWT';
|
const APP_AUTH_TYPE_JWT = 'JWT';
|
||||||
|
|
|
@ -39,6 +39,14 @@ $cli
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function notifyDeleteRealtimeUsage()
|
||||||
|
{
|
||||||
|
Resque::enqueue(Event::DELETE_QUEUE_NAME, Event::DELETE_CLASS_NAME, [
|
||||||
|
'type' => DELETE_TYPE_REALTIME,
|
||||||
|
'timestamp' => time() - 60
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
// # of days in seconds (1 day = 86400s)
|
// # of days in seconds (1 day = 86400s)
|
||||||
$interval = (int) App::getEnv('_APP_MAINTENANCE_INTERVAL', '86400');
|
$interval = (int) App::getEnv('_APP_MAINTENANCE_INTERVAL', '86400');
|
||||||
$executionLogsRetention = (int) App::getEnv('_APP_MAINTENANCE_RETENTION_EXECUTION', '1209600');
|
$executionLogsRetention = (int) App::getEnv('_APP_MAINTENANCE_RETENTION_EXECUTION', '1209600');
|
||||||
|
@ -51,5 +59,6 @@ $cli
|
||||||
notifyDeleteExecutionLogs($executionLogsRetention);
|
notifyDeleteExecutionLogs($executionLogsRetention);
|
||||||
notifyDeleteAbuseLogs($abuseLogsRetention);
|
notifyDeleteAbuseLogs($abuseLogsRetention);
|
||||||
notifyDeleteAuditLogs($auditLogRetention);
|
notifyDeleteAuditLogs($auditLogRetention);
|
||||||
|
notifyDeleteRealtimeUsage();
|
||||||
}, $interval);
|
}, $interval);
|
||||||
});
|
});
|
|
@ -69,6 +69,10 @@ class DeletesV1 extends Worker
|
||||||
$this->deleteAbuseLogs($this->args['timestamp']);
|
$this->deleteAbuseLogs($this->args['timestamp']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case DELETE_TYPE_REALTIME:
|
||||||
|
$this->deleteRealtimeUsage($this->args['timestamp']);
|
||||||
|
break;
|
||||||
|
|
||||||
case DELETE_TYPE_CERTIFICATES:
|
case DELETE_TYPE_CERTIFICATES:
|
||||||
$document = new Document($this->args['document']);
|
$document = new Document($this->args['document']);
|
||||||
$this->deleteCertificates($document);
|
$this->deleteCertificates($document);
|
||||||
|
@ -197,6 +201,19 @@ class DeletesV1 extends Worker
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function deleteRealtimeUsage($timestamp)
|
||||||
|
{
|
||||||
|
if (!($consoleDB = $this->getConsoleDB())) {
|
||||||
|
throw new Exception('Failed to get consoleDb.');
|
||||||
|
}
|
||||||
|
// Delete Dead Realtime Logs
|
||||||
|
$this->deleteByGroup([
|
||||||
|
'$collection='.Database::SYSTEM_COLLECTION_REALTIME_CONNECTIONS,
|
||||||
|
'timestamp<'.$timestamp
|
||||||
|
], $consoleDB);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected function deleteFunction(Document $document, $projectId)
|
protected function deleteFunction(Document $document, $projectId)
|
||||||
{
|
{
|
||||||
$projectDB = $this->getProjectDB($projectId);
|
$projectDB = $this->getProjectDB($projectId);
|
||||||
|
|
Loading…
Reference in a new issue