Add processor heartbeat management and improve health check functionality
All checks were successful
Publish FaceAI Container / publish (push) Successful in 3m7s
All checks were successful
Publish FaceAI Container / publish (push) Successful in 3m7s
- Introduced processor heartbeat configuration in environment variables and Docker setup. - Implemented heartbeat publishing in the processor worker. - Enhanced health check endpoint to include processor availability status. - Updated frontend components to handle processor unavailability messages. - Added legacy return functionality in the upload panel.
This commit is contained in:
parent
c0732c142c
commit
87d9238795
14 changed files with 292 additions and 23 deletions
|
|
@ -24,6 +24,10 @@ function rateLimitKey(userId) {
|
|||
return `faceai:rate-limit:${userId}`;
|
||||
}
|
||||
|
||||
function processorHeartbeatKey() {
|
||||
return 'faceai:processor-heartbeat';
|
||||
}
|
||||
|
||||
export async function incrementRateLimit(redis, userId, windowSeconds) {
|
||||
const key = rateLimitKey(userId);
|
||||
const count = await redis.incr(key);
|
||||
|
|
@ -50,6 +54,21 @@ export async function getActiveSearchId(redis, userId) {
|
|||
return redis.get(activeSearchKey(userId));
|
||||
}
|
||||
|
||||
export async function updateProcessorHeartbeat(redis, ttlSeconds, payload = {}) {
|
||||
const heartbeat = {
|
||||
updatedAt: Date.now(),
|
||||
...payload
|
||||
};
|
||||
|
||||
await redis.set(processorHeartbeatKey(), JSON.stringify(heartbeat), 'EX', ttlSeconds);
|
||||
return heartbeat;
|
||||
}
|
||||
|
||||
export async function getProcessorHeartbeat(redis) {
|
||||
const raw = await redis.get(processorHeartbeatKey());
|
||||
return raw ? JSON.parse(raw) : null;
|
||||
}
|
||||
|
||||
export async function createSearchRecord(redis, payload, ttlSeconds) {
|
||||
const searchId = randomId('search');
|
||||
const record = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue