Skip to content

Commit

Permalink
Add some helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardobl committed Apr 6, 2024
1 parent 0a71323 commit ae32e0a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/lib/Job.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,29 @@ class Job {


static async waitFor(jobId) {
jobId = await jobId;
const mem = Memory.fromString(jobId);
await Job_waitFor(mem.offset);
return Job.get(jobId);
}


static async pluginRequest(plugin, inputData, description, expireAfter) {
const req = {
runOn: "openagents/extism-runtime",
expireAfter: expireAfter || Date.now() + 1000 * 60 * 60,
description: description || "",
inputs: [
await Job.newInputData(JSON.stringify(inputData))
],
params: [
await Job.newParam("main", plugin)
],
kind: undefined,
outputFormat: undefined
};
const subReqId = (await Job.request(req)).id;
return subReqId;
}
}

Expand Down

0 comments on commit ae32e0a

Please sign in to comment.