@pgflow/edge-worker 0.0.10-prealpha.4 → 0.0.10-prealpha.6

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.
@@ -1 +1 @@
1
- {"version":3,"file":"WorkerLifecycle.d.ts","sourceRoot":"","sources":["../../src/core/WorkerLifecycle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,eAAe,EAAa,MAAM,YAAY,CAAC;AAE/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,eAAe,CAAC,QAAQ,SAAS,IAAI,CAAE,YAAW,UAAU;IACvE,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,SAAS,CAAC,CAAY;IAC9B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,KAAK,CAAkB;IAC/B,OAAO,CAAC,SAAS,CAAC,CAAY;gBAElB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM;IAO9D,gBAAgB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBvE,eAAe;IAyBf,IAAI,gBAAgB,uBAEnB;IAED,IAAI,SAAS,WAEZ;IAEK,aAAa;IAInB,IAAI,SAAS,YAEZ;IAED,IAAI,UAAU,YAEb;IAED,IAAI,SAAS,YAEZ;IAED,oBAAoB;CAGrB"}
1
+ {"version":3,"file":"WorkerLifecycle.d.ts","sourceRoot":"","sources":["../../src/core/WorkerLifecycle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,eAAe,EAAa,MAAM,YAAY,CAAC;AAE/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,eAAe,CAAC,QAAQ,SAAS,IAAI,CAAE,YAAW,UAAU;IACvE,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,SAAS,CAAC,CAAY;IAC9B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,KAAK,CAAkB;IAC/B,OAAO,CAAC,SAAS,CAAC,CAAY;gBAElB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM;IAO9D,gBAAgB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBvE,eAAe;IAyBf,IAAI,gBAAgB,uBAEnB;IAED,IAAI,SAAS,WAEZ;IAEK,aAAa;IAInB,IAAI,SAAS,YAEZ;IAED,IAAI,UAAU,YAEb;IAED,IAAI,SAAS,YAEZ;IAED,oBAAoB;CAGrB"}
@@ -15,7 +15,7 @@ export class WorkerLifecycle {
15
15
  }
16
16
  async acknowledgeStart(workerBootstrap) {
17
17
  this.workerState.transitionTo(States.Starting);
18
- this.logger.info(`Ensuring queue '${this.queue.queueName}' exists...`);
18
+ console.log(`Ensuring queue '${this.queue.queueName}' exists...`);
19
19
  await this.queue.safeCreate();
20
20
  this.workerRow = await this.queries.onWorkerStarted({
21
21
  queueName: this.queueName,
@@ -30,7 +30,7 @@ export class WorkerLifecycle {
30
30
  throw new Error('Cannot stop worker: workerRow not set');
31
31
  }
32
32
  try {
33
- this.logger.debug('Acknowledging worker stop...');
33
+ console.log('Acknowledging worker stop...');
34
34
  // TODO: commented out because we can live without this
35
35
  // but it is causing problems with DbHandler - workes does not have
36
36
  // enough time to fire this query before hard-terimnated
@@ -38,10 +38,10 @@ export class WorkerLifecycle {
38
38
  //
39
39
  // await this.queries.onWorkerStopped(this.workerRow);
40
40
  this.workerState.transitionTo(States.Stopped);
41
- this.logger.debug('Worker stop acknowledged');
41
+ console.log('Worker stop acknowledged');
42
42
  }
43
43
  catch (error) {
44
- this.logger.debug(`Error acknowledging worker stop: ${error}`);
44
+ console.log(`Error acknowledging worker stop: ${error}`);
45
45
  throw error;
46
46
  }
47
47
  }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgflow/edge-worker",
3
- "version": "0.0.10-prealpha.4",
3
+ "version": "0.0.10-prealpha.6",
4
4
  "license": "AGPL-3.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -12,9 +12,6 @@ export declare class DenoAdapter implements PlatformAdapter {
12
12
  terminate(): Promise<void>;
13
13
  getEnv(): PlatformEnvironment;
14
14
  createLogger(module: string): Logger;
15
- setWorker(worker: {
16
- stop(): void;
17
- }): void;
18
15
  spawnNewEdgeFunction(functionName: string): Promise<void>;
19
16
  private detectEnvironment;
20
17
  private extractFunctionName;
@@ -1 +1 @@
1
- {"version":3,"file":"DenoAdapter.d.ts","sourceRoot":"","sources":["../../src/platform/DenoAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,MAAM,EACN,eAAe,EACf,mBAAmB,EACpB,MAAM,YAAY,CAAC;AACpB,OAAO,iBAAiB,CAAC;AAEzB;;GAEG;AACH,qBAAa,WAAY,YAAW,eAAe;IACjD,OAAO,CAAC,GAAG,CAAsB;IACjC,OAAO,CAAC,gBAAgB,CAAuB;IAC/C,OAAO,CAAC,MAAM,CAAiC;;IAezC,UAAU,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBzD,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAOhC,MAAM,IAAI,mBAAmB;IAI7B,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IA6CpC,SAAS,CAAC,MAAM,EAAE;QAAE,IAAI,IAAI,IAAI,CAAA;KAAE,GAAG,IAAI;IAInC,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA+B/D,OAAO,CAAC,iBAAiB;IAsBzB,OAAO,CAAC,mBAAmB;IAI3B,oBAAoB,IAAI,IAAI;CAY7B"}
1
+ {"version":3,"file":"DenoAdapter.d.ts","sourceRoot":"","sources":["../../src/platform/DenoAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,MAAM,EACN,eAAe,EACf,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAEpB,OAAO,iBAAiB,CAAC;AAEzB;;GAEG;AACH,qBAAa,WAAY,YAAW,eAAe;IACjD,OAAO,CAAC,GAAG,CAAsB;IACjC,OAAO,CAAC,gBAAgB,CAAuB;IAC/C,OAAO,CAAC,MAAM,CAAuB;;IAe/B,UAAU,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA4BzD,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAMhC,MAAM,IAAI,mBAAmB;IAI7B,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IA6C9B,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA+B/D,OAAO,CAAC,iBAAiB;IAsBzB,OAAO,CAAC,mBAAmB;IAI3B,oBAAoB,IAAI,IAAI;CAW7B"}
@@ -25,6 +25,10 @@ export class DenoAdapter {
25
25
  logger.info(`HTTP Request: ${this.edgeFunctionName}`);
26
26
  // Create the worker using the factory function and the logger
27
27
  this.worker = createWorkerFn(this.createLogger.bind(this));
28
+ this.worker.startOnlyOnce({
29
+ edgeFunctionName: this.edgeFunctionName,
30
+ workerId: this.env.executionId,
31
+ });
28
32
  }
29
33
  return new Response('ok', {
30
34
  headers: { 'Content-Type': 'application/json' },
@@ -36,8 +40,7 @@ export class DenoAdapter {
36
40
  }
37
41
  async terminate() {
38
42
  if (this.worker) {
39
- this.worker.stop();
40
- this.worker = null;
43
+ await this.worker.stop();
41
44
  }
42
45
  }
43
46
  getEnv() {
@@ -73,9 +76,6 @@ export class DenoAdapter {
73
76
  },
74
77
  };
75
78
  }
76
- setWorker(worker) {
77
- this.worker = worker;
78
- }
79
79
  async spawnNewEdgeFunction(functionName) {
80
80
  if (!functionName) {
81
81
  throw new Error('functionName cannot be null or empty');
@@ -122,8 +122,7 @@ export class DenoAdapter {
122
122
  await this.spawnNewEdgeFunction(this.edgeFunctionName);
123
123
  }
124
124
  if (this.worker) {
125
- this.worker.stop();
126
- this.worker = null;
125
+ await this.worker.stop();
127
126
  }
128
127
  };
129
128
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgflow/edge-worker",
3
- "version": "0.0.10-prealpha.4",
3
+ "version": "0.0.10-prealpha.6",
4
4
  "license": "AGPL-3.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",