Skip to content

Instantly share code, notes, and snippets.

@abidkhan484
Created July 2, 2024 05:49
Show Gist options
  • Save abidkhan484/770bbed4b19f11143f062c3af13963ea to your computer and use it in GitHub Desktop.
Save abidkhan484/770bbed4b19f11143f062c3af13963ea to your computer and use it in GitHub Desktop.
Fringcore cluster lock challenge
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