|
|
|
@ -2,12 +2,21 @@ export const IMAGES = {
|
|
|
|
|
moshell: 'ghcr.io/moshell-lang/moshell:master',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Prepares a buffer to be sent to the runner.
|
|
|
|
|
*
|
|
|
|
|
* @param jobId The job unique identifier.
|
|
|
|
|
* @param code The code to be executed.
|
|
|
|
|
* @param image The image to be used.
|
|
|
|
|
*/
|
|
|
|
|
export function allocateBuffer(jobId: string, code: string, image: string): Buffer {
|
|
|
|
|
const buffer = Buffer.allocUnsafe(jobId.length + image.length + code.length + 8);
|
|
|
|
|
buffer.write(jobId, 0);
|
|
|
|
|
buffer.writeUInt32BE(image.length, jobId.length);
|
|
|
|
|
buffer.writeUInt32BE(code.length, jobId.length + 4);
|
|
|
|
|
buffer.write(image, jobId.length + 8);
|
|
|
|
|
buffer.write(code, jobId.length + 8 + image.length);
|
|
|
|
|
let cur = 0;
|
|
|
|
|
const buffer = Buffer.allocUnsafe(jobId.length + image.length + code.length + 9);
|
|
|
|
|
cur = buffer.writeUInt8(0, cur);
|
|
|
|
|
cur += buffer.write(jobId, cur);
|
|
|
|
|
cur = buffer.writeUInt32BE(image.length, cur);
|
|
|
|
|
cur = buffer.writeUInt32BE(code.length, cur);
|
|
|
|
|
cur += buffer.write(image, cur);
|
|
|
|
|
buffer.write(code, cur);
|
|
|
|
|
return buffer;
|
|
|
|
|
}
|
|
|
|
|