pmcf 1.62.0 → 1.63.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "1.62.0",
3
+ "version": "1.63.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/cluster.mjs CHANGED
@@ -51,6 +51,10 @@ export class Cluster extends Host {
51
51
  return this.#backups;
52
52
  }
53
53
 
54
+ get members() {
55
+ return this.masters.union(this.backups);
56
+ }
57
+
54
58
  async *preparePackages(stagingDir) {
55
59
  const result = {
56
60
  sources: [],
@@ -93,6 +97,31 @@ export class Cluster extends Host {
93
97
  cfg.push(" }");
94
98
  cfg.push("}");
95
99
  cfg.push("");
100
+
101
+ for (const service of cluster.findServices({ type: "http" })) {
102
+ console.log("S",service.host.name,service.name);
103
+ cfg.push(`virtual_server ${cluster.rawAddress} ${service.port} {`);
104
+ cfg.push(" delay_loop 6");
105
+ cfg.push(" lb_algo wlc");
106
+ cfg.push(" persistence_timeout 600");
107
+ cfg.push(` protocol ${service.protocol.toUpperCase()}`);
108
+
109
+ for (const member of this.members) {
110
+ cfg.push(` real_server ${member.rawAddress} ${service.port} {`);
111
+ cfg.push(" weight 100");
112
+
113
+ if (service.protocol === "tcp") {
114
+ cfg.push(` TCP_CHECK {`);
115
+ cfg.push(" connect_timeout 3");
116
+ cfg.push(" }");
117
+ }
118
+
119
+ cfg.push(" }");
120
+ }
121
+
122
+ cfg.push("}");
123
+ cfg.push("");
124
+ }
96
125
  }
97
126
 
98
127
  await writeLines(
package/src/host.mjs CHANGED
@@ -254,8 +254,12 @@ export class Host extends Base {
254
254
  return this.#services;
255
255
  }
256
256
 
257
- set services(services) {
258
- this.#services.push(services);
257
+ set services(service) {
258
+ const present = this.#services.find(s => s.name === service.name);
259
+
260
+ if (!present) {
261
+ this.#services.push(service);
262
+ }
259
263
  }
260
264
 
261
265
  *findServices(filter) {
@@ -381,6 +381,7 @@ export class Cluster extends Host {
381
381
  get masters(): Set<any>;
382
382
  set backups(value: Set<any>);
383
383
  get backups(): Set<any>;
384
+ get members(): Set<any>;
384
385
  preparePackages(stagingDir: any): AsyncGenerator<{
385
386
  sources: any[];
386
387
  properties: {
package/types/host.d.mts CHANGED
@@ -151,7 +151,7 @@ export class Host extends Base {
151
151
  get provides(): Set<any>;
152
152
  set replaces(value: Set<any>);
153
153
  get replaces(): Set<any>;
154
- set services(services: any[]);
154
+ set services(service: any[]);
155
155
  get services(): any[];
156
156
  _traverse(...args: any[]): boolean;
157
157
  set deployment(value: any);