geonix 1.20.0 → 1.20.1

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/index.d.ts CHANGED
@@ -77,21 +77,27 @@ declare class Registry {
77
77
  export {};
78
78
  export function Remote(service: string, ...context: (string | Stream | Object)[]): string | Stream | Object;
79
79
  /**
80
+ * Send a request to a service
80
81
  *
81
- * @param {*} service
82
- * @param {*} method
83
- * @param {*} args
82
+ * @param {string} service
83
+ * @param {string} method
84
+ * @param {any[]} args
85
+ * @param {any[]} context
86
+ * @param {object} options
84
87
  * @returns
85
88
  */
86
- export function Request(service: any, method: any, args: any, context: any[] | undefined, options: any): Promise<any>;
89
+ export function Request(service: string, method: string, args: any[], context: any[], options: object): Promise<any>;
87
90
  /**
91
+ * Send a request to a service
88
92
  *
89
- * @param {*} service
90
- * @param {*} method
91
- * @param {*} args
93
+ * @param {string} identifier
94
+ * @param {string} method
95
+ * @param {any[]} args
96
+ * @param {any[]} context
97
+ * @param {object} options
92
98
  * @returns
93
99
  */
94
- export function directRequest(identifier: any, method: any, args: any, context: any[] | undefined, options: any, service: any): Promise<any>;
100
+ export function directRequest(identifier: string, method: string, args: any[], context: any[], options: object, service: any): Promise<any>;
95
101
  /**
96
102
  * Publish payload to a subject
97
103
  *
@@ -115,7 +121,6 @@ export function RequestOptions(options: any): RequestOptionsClass;
115
121
  export class Service {
116
122
  static serviceClasses: any[];
117
123
  static start(options?: {}): void;
118
- static static(): void;
119
124
  connections: Map<any, any>;
120
125
  $createConnection(streamId: any): Promise<boolean>;
121
126
  $getEnv(): {
@@ -152,6 +157,7 @@ export const stats: {};
152
157
  * @returns
153
158
  */
154
159
  export function parseURL(url: string): any;
160
+ export function getFirstItemFromAsyncIterable(asyncIterable: any): Promise<any>;
155
161
  export function sleep(delay: number): Promise<any>;
156
162
  export function picoid(size?: number): any;
157
163
  export function hash(data: string | Buffer): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geonix",
3
- "version": "1.20.0",
3
+ "version": "1.20.1",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "bin": {
package/src/Connection.js CHANGED
@@ -72,7 +72,9 @@ class Connection {
72
72
  * Wait for the connection to be safely closed
73
73
  */
74
74
  async waitUntilClosed() {
75
- await this.#getConnection().closed();
75
+ // wait for all connections to be closed
76
+ await Promise.all(this.#connections.map(connection => connection.closed()));
77
+
76
78
  this.#closed = true;
77
79
  console.log("gx.connection.closed");
78
80
 
@@ -181,9 +183,7 @@ class Connection {
181
183
  async drain() {
182
184
  this.#draining = true;
183
185
 
184
- for (let connection of this.#connections) {
185
- await connection.drain();
186
- }
186
+ await Promise.all(this.#connections.map(connection => connection.drain()));
187
187
  }
188
188
 
189
189
  }
package/src/Gateway.js CHANGED
@@ -163,20 +163,22 @@ export class Gateway {
163
163
 
164
164
  // figure out if endpoints is reachable via direct http call
165
165
  let backend;
166
- for (let address of entry.a)
167
- try {
168
- const ac = new AbortController();
169
- const timeout = setTimeout(() => ac.abort(), 500);
170
- const result = await (await fetch(`http://${address}${HEALTH_CHECK_ENDPOINT}`, { signal: ac.signal })).json();
171
- clearTimeout(timeout);
172
- if (result.status === "healthy" && result.services?.includes(entry.n)) {
173
- backend = address;
174
- console.log(`${entry.n}@${entry.v} (#${entry.i}) directly reachable @ ${address}`);
175
- break;
166
+ if (entry.a) {
167
+ for (let address of entry.a)
168
+ try {
169
+ const ac = new AbortController();
170
+ const timeout = setTimeout(() => ac.abort(), 500);
171
+ const result = await (await fetch(`http://${address}${HEALTH_CHECK_ENDPOINT}`, { signal: ac.signal })).json();
172
+ clearTimeout(timeout);
173
+ if (result.status === "healthy" && result.services?.includes(entry.n)) {
174
+ backend = address;
175
+ console.log(`${entry.n}@${entry.v} (#${entry.i}) directly reachable @ ${address}`);
176
+ break;
177
+ }
178
+ } catch {
179
+ // silently ignore errors
176
180
  }
177
- } catch {
178
- // silently ignore errors
179
- }
181
+ }
180
182
 
181
183
  let proxy;
182
184
  if (!backend) {