Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/backend/conat/test/cluster/bench.ts
1712 views
1
/*
2
create a cluster consisting of $n$ distinct nodejs processes, each
3
listening on separate ports on localhost. They are all connected.
4
*/
5
6
interface Node {
7
port: number;
8
child; // the spawned child process
9
}
10
11
export class Cluster {
12
nodes: Node[] = [];
13
14
constructor(public N: number) {}
15
16
init = async () => {
17
for (let i = 0; i < this.N; i++) {
18
19
}
20
};
21
}
22
23
export async function createCluster(N: number): Promise<Cluster> {
24
const C = new Cluster(N);
25
await C.init();
26
return C;
27
}
28
29