@@ -142,7 +142,11 @@ export interface Options {
142142 // if true, use https when creating an internal client.
143143 ssl ?: boolean ;
144144
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...
146150 //
147151 // if clusterName is set, enable clustering. Each node
148152 // in the cluster must have a different name. systemAccountPassword
@@ -456,8 +460,12 @@ export class ConatServer extends EventEmitter {
456460 this . stickyClient = this . client ( {
457461 systemAccountPassword : this . options . systemAccountPassword ,
458462 } ) ;
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.
461469 createStickyRouter ( { client : this . stickyClient } ) ;
462470 }
463471 } ;
@@ -1105,7 +1113,10 @@ export class ConatServer extends EventEmitter {
11051113 if ( localClusterSize < 2 ) {
11061114 return ;
11071115 }
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.
11091120 const port = this . options . port ;
11101121 if ( ! port ) {
11111122 throw Error ( "bug -- port must be set" ) ;
0 commit comments