Created
July 2, 2024 05:49
-
-
Save abidkhan484/770bbed4b19f11143f062c3af13963ea to your computer and use it in GitHub Desktop.
Fringcore cluster lock challenge
This file contains hidden or 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
import { send, doWork } from "./lib.mjs"; | |
import cluster from "node:cluster"; | |
const NAME = process.env.NAME; | |
export async function onMessage(message) { | |
if (cluster.worker.message !== message) { | |
cluster.worker.message = message; | |
} else { | |
return; | |
} | |
} | |
export async function onStart() { | |
cluster.worker.message = ""; | |
console.log(`START: ${NAME}`); | |
} | |
export async function onRequest(word) { | |
if (cluster.worker.message !== word) { | |
await send(word); | |
} else { | |
return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment