Last active
December 27, 2018 12:13
-
-
Save herecydev/6f053cdb4319d2be76a4b46ef49d609f to your computer and use it in GitHub Desktop.
timehandler.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const taskHandler = async (task) => { | |
try { | |
const start = Date.now(); | |
log.info("Executing {taskId}", { taskId: task.taskId }); | |
const handler = await import(`handlers/${task.taskId}`); | |
const result = await handler.execute(task); | |
const end = Date.now(); | |
log.info("Task Handler {taskId} succeeded in {time}ms", { taskId: task.taskId, time: end - start }); | |
return result; | |
} | |
catch (error) { | |
log.error(error, "Task Handler {taskId} failed", { taskId: task.taskId }); | |
return -1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment