refactor(server): indexer & worker & sync perf (#15504)

This commit is contained in:
DarkSky
2026-08-21 08:11:37 +08:00
committed by GitHub
parent 8c9aad9a9b
commit c57004ea2c
259 changed files with 16530 additions and 17793 deletions

View File

@@ -24,10 +24,17 @@ export enum Flavor {
Sync = 'sync',
Renderer = 'renderer',
Front = 'front',
Doc = 'doc',
Worker = 'worker',
Script = 'script',
}
export enum ServerRole {
Frontend = 'frontend',
Api = 'api',
Worker = 'worker',
AllInOne = 'allinone',
}
export enum Namespace {
Dev = 'dev',
Beta = 'beta',
@@ -101,6 +108,39 @@ export class Env implements AppEnv {
return this.DEPLOYMENT_TYPE === DeploymentType.Selfhosted;
}
get role(): ServerRole | undefined {
switch (this.FLAVOR) {
case Flavor.AllInOne:
return ServerRole.AllInOne;
case Flavor.Graphql:
return ServerRole.Api;
case Flavor.Worker:
return ServerRole.Worker;
case Flavor.Front:
case Flavor.Sync:
case Flavor.Renderer:
return ServerRole.Frontend;
case Flavor.Script:
return undefined;
}
}
get isApi() {
return this.FLAVOR === Flavor.Graphql || this.FLAVOR === Flavor.AllInOne;
}
get isWorker() {
return this.FLAVOR === Flavor.Worker || this.FLAVOR === Flavor.AllInOne;
}
get isFrontend() {
return (
this.FLAVOR === Flavor.Front ||
this.FLAVOR === Flavor.Sync ||
this.FLAVOR === Flavor.Renderer
);
}
isFlavor(flavor: Flavor) {
return this.FLAVOR === flavor || this.FLAVOR === Flavor.AllInOne;
}
@@ -111,7 +151,7 @@ export class Env implements AppEnv {
sync: this.isFlavor(Flavor.Sync),
renderer: this.isFlavor(Flavor.Renderer),
front: this.FLAVOR === Flavor.Front,
doc: this.isFlavor(Flavor.Doc),
worker: this.isFlavor(Flavor.Worker),
// Script in a special flavor, return true only when it is set explicitly
script: this.FLAVOR === Flavor.Script,
};