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

Function pollJob

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

Source from the content-addressed store, hash-verified

192}
193
194async function pollJob(config, state) {
195 if (
196 state.activeSessions.size + state.inFlightAllocations >=
197 config.maxCapacity
198 ) {
199 return;
200 }
201 const response = await studioJson(
202 config,
203 "/api/actions/provider-hosts/jobs/next",
204 {
205 hostId: config.hostId,
206 hostToken: config.hostToken,
207 },
208 );
209 if (!response?.job) {
210 return;
211 }
212 const task = handleJob(config, state, response.job).catch((error) => {
213 console.error(
214 `[simdeck-provider] job ${response.job.id} failed: ${describeError(error)}`,
215 );
216 });
217 state.activeRequests.add(task);
218 task.finally(() => state.activeRequests.delete(task));
219}
220
221async function handleJob(config, state, job) {
222 if (job.type === "allocate") {

Callers 1

runFunction · 0.85

Calls 5

studioJsonFunction · 0.85
handleJobFunction · 0.85
errorMethod · 0.80
describeErrorFunction · 0.70
deleteMethod · 0.65

Tested by

no test coverage detected