-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: stub cluster module in bundles
- Loading branch information
Showing
3 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const EventEmitter = require('events') | ||
|
||
const makeMethod = (key) => { | ||
// Not an arrow as Worker is a class and can be called with new | ||
return function () { | ||
throw new Error(`cluster.${key} unsupported in bundled mode`) | ||
} | ||
} | ||
|
||
const cluster = new EventEmitter() | ||
|
||
Object.assign(cluster, { | ||
isWorker: false, | ||
isPrimary: true, | ||
workers: {}, | ||
settings: {}, | ||
SCHED_NONE: 1, | ||
SCHED_RR: 2, | ||
schedulingPolicy: 2, | ||
}) | ||
|
||
for (const key of ['Worker', 'setupPrimary', 'fork', 'disconnect']) cluster[key] = makeMethod(key) | ||
|
||
cluster.isMaster = cluster.isPrimary | ||
cluster.setupMaster = cluster.setupPrimary | ||
|
||
module.exports = cluster |
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