Skip to content

Commit

Permalink
Updated lambda calling
Browse files Browse the repository at this point in the history
  • Loading branch information
TwoAbove committed Sep 8, 2024
1 parent d8d2ea0 commit 989ef4d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions server/io/compute.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ export const counts = {
};
const users = {};

setInterval(() => {
console.info(users);
}, 5000);

const registerUserSocket = (userId, socketId, type, appetite = 0) => {
if (!users[userId]) {
users[userId] = { hosts: new Set(), workers: new Set() };
Expand Down Expand Up @@ -60,8 +56,13 @@ const pingLambda = () => {
};

setInterval(() => {
console.info(users);
if (counts.hosts > 0) {
pingLambda();
const userWithHostsAndCompute = Object.values(users).some(user => user.hosts.size > 0 && user.computeLeft > 0);

if (userWithHostsAndCompute) {
pingLambda();
}
}
}, 10000);

Expand Down

0 comments on commit 989ef4d

Please sign in to comment.