Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 1x 2x 2x 1x | // Part IV - Job state.
// In a real setup the successful job state (key: tags, value: link/object name)
// would live in a database. Because the worker runs on the same instance as the
// API for this experiment, we just keep it in a static/global in-memory map.
const completedJobs = new Map();
function normalizeKey(tags) {
return String(tags || '').trim().toLowerCase();
}
// Record that the zip for these tags is ready, storing the object name in GCS.
function markComplete(tags, objectName) {
completedJobs.set(normalizeKey(tags), objectName);
}
// Returns the GCS object name for a finished job, or undefined if not ready yet.
function getObjectName(tags) {
return completedJobs.get(normalizeKey(tags));
}
module.exports = {
markComplete,
getObjectName,
completedJobs
};
|