diff --git a/src/daemon/index.ts b/src/daemon/index.ts index 643fd62..f34fb94 100644 --- a/src/daemon/index.ts +++ b/src/daemon/index.ts @@ -6,7 +6,7 @@ import util = require('util'); import rmq = require('./rmq'); import remote = require('./remote'); import { judge } from './judge'; -import { JudgeResult, ErrorType, ProgressReportType, OverallResult } from '../interfaces'; +import { JudgeResult, ErrorType, ProgressReportType, OverallResult, SerializedBuffer } from '../interfaces'; (async function () { winston.info("Daemon starts."); @@ -14,6 +14,11 @@ import { JudgeResult, ErrorType, ProgressReportType, OverallResult } from '../in await rmq.connect(); winston.info("Start consuming the queue."); await remote.waitForTask(async (task) => { + if (task.extraData) { + const extraData: SerializedBuffer = task.extraData as any as SerializedBuffer; + if (extraData.type === "Buffer") task.extraData = new Buffer(extraData.data); + } + let result: OverallResult; try { await remote.reportProgress({ taskId: task.content.taskId, type: ProgressReportType.Started, progress: null }); diff --git a/src/interfaces.ts b/src/interfaces.ts index c8c3fc8..d29217b 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -161,5 +161,10 @@ export interface RPCReply { error?: string; } +export interface SerializedBuffer { + type: string; + data: Uint8Array; +} + export const redisBinarySuffix = '-bin'; export const redisMetadataSuffix = '-meta';