@@ -142,7 +142,11 @@ export interface Options {
142
142
// if true, use https when creating an internal client.
143
143
ssl ?: boolean ;
144
144
145
- // WARNING: **superclusters are NOT fully iplemented yet.**
145
+ // WARNING: **superclusters are NOT implemented yet**. Maybe they
146
+ // are a very bad idea and should NOT be implemented. In practice,
147
+ // when I hit a need for this it's better to just explicitly make
148
+ // a process with two clients, and use an explicit protocol to
149
+ // connect the clusters...
146
150
//
147
151
// if clusterName is set, enable clustering. Each node
148
152
// in the cluster must have a different name. systemAccountPassword
@@ -456,8 +460,12 @@ export class ConatServer extends EventEmitter {
456
460
this . stickyClient = this . client ( {
457
461
systemAccountPassword : this . options . systemAccountPassword ,
458
462
} ) ;
459
- if ( ! this . cluster ) {
460
- // not a cluster, so we can server as the sticky routing serivce
463
+ if ( ! this . cluster || this . options . localClusterSize != null ) {
464
+ // not a cluster or a local cluster, so we view THIS server
465
+ // as the canonical server and it also hosts the
466
+ // sticky routing service. The one case where we don't do
467
+ // this is for a non-local cluster, e.g., deploying on
468
+ // Kubernetes.
461
469
createStickyRouter ( { client : this . stickyClient } ) ;
462
470
}
463
471
} ;
@@ -1105,7 +1113,10 @@ export class ConatServer extends EventEmitter {
1105
1113
if ( localClusterSize < 2 ) {
1106
1114
return ;
1107
1115
}
1108
- // spawn additional servers as separate processes to form a cluster
1116
+ // Spawn additional servers as *separate processes* to form a cluster.
1117
+ // This is mainly used for testing, but is also very useful on
1118
+ // a single powerful machine where we want more routing than a single
1119
+ // nodejs process provides. This cannot do autoscaling though.
1109
1120
const port = this . options . port ;
1110
1121
if ( ! port ) {
1111
1122
throw Error ( "bug -- port must be set" ) ;
0 commit comments