@nocobase/server 2.4.0-alpha.12 → 2.4.0-alpha.13

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.
@@ -201,6 +201,14 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
201
201
  static addCommand(callback: (app: Application) => void): void;
202
202
  private _sqlLogger;
203
203
  get instanceId(): number;
204
+ /**
205
+ * Adopt a worker id handed out at runtime, after the allocator loses its lease and acquires a different one. Ids may
206
+ * only be minted under a worker id this process currently holds, so the generator is rebuilt to match.
207
+ *
208
+ * Returning early on an unchanged id is required rather than an optimisation: rebuilding restarts the sequence at 0,
209
+ * so doing it for the same worker id inside one second would re-issue ids this process has already handed out.
210
+ */
211
+ setInstanceId(instanceId: number): void;
204
212
  get sqlLogger(): Logger;
205
213
  protected _logger: SystemLogger;
206
214
  get logger(): SystemLogger;
@@ -154,6 +154,21 @@ const _Application = class _Application extends import_koa.default {
154
154
  get instanceId() {
155
155
  return this._instanceId;
156
156
  }
157
+ /**
158
+ * Adopt a worker id handed out at runtime, after the allocator loses its lease and acquires a different one. Ids may
159
+ * only be minted under a worker id this process currently holds, so the generator is rebuilt to match.
160
+ *
161
+ * Returning early on an unchanged id is required rather than an optimisation: rebuilding restarts the sequence at 0,
162
+ * so doing it for the same worker id inside one second would re-issue ids this process has already handed out.
163
+ */
164
+ setInstanceId(instanceId) {
165
+ if (this._instanceId === instanceId) {
166
+ return;
167
+ }
168
+ this._instanceId = instanceId;
169
+ this.snowflakeIdGenerator = new import_snowflake_id.Snowflake({ workerId: instanceId });
170
+ this.log.info(`adopt worker id: ${instanceId}`, { method: "setInstanceId" });
171
+ }
157
172
  get sqlLogger() {
158
173
  return this._sqlLogger;
159
174
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/server",
3
- "version": "2.4.0-alpha.12",
3
+ "version": "2.4.0-alpha.13",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "license": "Apache-2.0",
@@ -10,21 +10,21 @@
10
10
  "@koa/cors": "^5.0.0",
11
11
  "@koa/multer": "^3.1.0",
12
12
  "@koa/router": "^13.1.0",
13
- "@nocobase/acl": "2.4.0-alpha.12",
14
- "@nocobase/actions": "2.4.0-alpha.12",
15
- "@nocobase/ai": "2.4.0-alpha.12",
16
- "@nocobase/auth": "2.4.0-alpha.12",
17
- "@nocobase/cache": "2.4.0-alpha.12",
18
- "@nocobase/data-source-manager": "2.4.0-alpha.12",
19
- "@nocobase/database": "2.4.0-alpha.12",
20
- "@nocobase/evaluators": "2.4.0-alpha.12",
21
- "@nocobase/lock-manager": "2.4.0-alpha.12",
22
- "@nocobase/logger": "2.4.0-alpha.12",
23
- "@nocobase/resourcer": "2.4.0-alpha.12",
24
- "@nocobase/sdk": "2.4.0-alpha.12",
25
- "@nocobase/snowflake-id": "2.4.0-alpha.12",
26
- "@nocobase/telemetry": "2.4.0-alpha.12",
27
- "@nocobase/utils": "2.4.0-alpha.12",
13
+ "@nocobase/acl": "2.4.0-alpha.13",
14
+ "@nocobase/actions": "2.4.0-alpha.13",
15
+ "@nocobase/ai": "2.4.0-alpha.13",
16
+ "@nocobase/auth": "2.4.0-alpha.13",
17
+ "@nocobase/cache": "2.4.0-alpha.13",
18
+ "@nocobase/data-source-manager": "2.4.0-alpha.13",
19
+ "@nocobase/database": "2.4.0-alpha.13",
20
+ "@nocobase/evaluators": "2.4.0-alpha.13",
21
+ "@nocobase/lock-manager": "2.4.0-alpha.13",
22
+ "@nocobase/logger": "2.4.0-alpha.13",
23
+ "@nocobase/resourcer": "2.4.0-alpha.13",
24
+ "@nocobase/sdk": "2.4.0-alpha.13",
25
+ "@nocobase/snowflake-id": "2.4.0-alpha.13",
26
+ "@nocobase/telemetry": "2.4.0-alpha.13",
27
+ "@nocobase/utils": "2.4.0-alpha.13",
28
28
  "@types/ini": "^1.3.31",
29
29
  "@types/koa-send": "^4.1.3",
30
30
  "@types/multer": "^1.4.12",
@@ -60,5 +60,5 @@
60
60
  "@types/serve-handler": "^6.1.1",
61
61
  "@types/ws": "^8.5.5"
62
62
  },
63
- "gitHead": "de0ec0596d238752ed56bae95600a59395c920ea"
63
+ "gitHead": "4f8b779e0efb365eabff87294a9eb222cec4ed55"
64
64
  }