MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / handleJob

Function handleJob

scripts/studio-host-provider.mjs:221–243  ·  view source on GitHub ↗
(config, state, job)

Source from the content-addressed store, hash-verified

219}
220
221async function handleJob(config, state, job) {
222 if (job.type === "allocate") {
223 if (
224 state.activeSessions.size + state.inFlightAllocations >=
225 config.maxCapacity
226 ) {
227 return;
228 }
229 state.inFlightAllocations += 1;
230 try {
231 await allocateSession(config, state, job);
232 } finally {
233 state.inFlightAllocations = Math.max(0, state.inFlightAllocations - 1);
234 }
235 } else if (job.type === "release") {
236 await releaseSession(config, state, job);
237 } else {
238 await completeJob(config, job.id, {
239 error: `Unsupported provider job type: ${job.type}`,
240 status: "failed",
241 });
242 }
243}
244
245async function allocateSession(config, state, job) {
246 const payload = job.payload || {};

Callers 1

pollJobFunction · 0.85

Calls 4

allocateSessionFunction · 0.85
releaseSessionFunction · 0.85
completeJobFunction · 0.85
maxMethod · 0.80

Tested by

no test coverage detected