mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-27 19:02:23 +08:00
chore(server): support dynamic disable indexer (#12498)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved system stability by ensuring that indexing jobs do not run when the indexer feature is disabled. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -40,6 +40,10 @@ export class IndexerJob {
|
|||||||
|
|
||||||
@OnJob('indexer.indexDoc')
|
@OnJob('indexer.indexDoc')
|
||||||
async indexDoc({ workspaceId, docId }: Jobs['indexer.indexDoc']) {
|
async indexDoc({ workspaceId, docId }: Jobs['indexer.indexDoc']) {
|
||||||
|
if (!this.config.indexer.enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// delete the 'indexer.deleteDoc' job from the queue
|
// delete the 'indexer.deleteDoc' job from the queue
|
||||||
await this.queue.remove(
|
await this.queue.remove(
|
||||||
`deleteDoc/${workspaceId}/${docId}`,
|
`deleteDoc/${workspaceId}/${docId}`,
|
||||||
@@ -50,6 +54,10 @@ export class IndexerJob {
|
|||||||
|
|
||||||
@OnJob('indexer.deleteDoc')
|
@OnJob('indexer.deleteDoc')
|
||||||
async deleteDoc({ workspaceId, docId }: Jobs['indexer.deleteDoc']) {
|
async deleteDoc({ workspaceId, docId }: Jobs['indexer.deleteDoc']) {
|
||||||
|
if (!this.config.indexer.enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// delete the 'indexer.updateDoc' job from the queue
|
// delete the 'indexer.updateDoc' job from the queue
|
||||||
await this.queue.remove(
|
await this.queue.remove(
|
||||||
`indexDoc/${workspaceId}/${docId}`,
|
`indexDoc/${workspaceId}/${docId}`,
|
||||||
@@ -60,6 +68,10 @@ export class IndexerJob {
|
|||||||
|
|
||||||
@OnJob('indexer.indexWorkspace')
|
@OnJob('indexer.indexWorkspace')
|
||||||
async indexWorkspace({ workspaceId }: Jobs['indexer.indexWorkspace']) {
|
async indexWorkspace({ workspaceId }: Jobs['indexer.indexWorkspace']) {
|
||||||
|
if (!this.config.indexer.enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await this.queue.remove(workspaceId, 'indexer.deleteWorkspace');
|
await this.queue.remove(workspaceId, 'indexer.deleteWorkspace');
|
||||||
const workspace = await this.models.workspace.get(workspaceId);
|
const workspace = await this.models.workspace.get(workspaceId);
|
||||||
if (!workspace) {
|
if (!workspace) {
|
||||||
@@ -127,6 +139,10 @@ export class IndexerJob {
|
|||||||
|
|
||||||
@OnJob('indexer.deleteWorkspace')
|
@OnJob('indexer.deleteWorkspace')
|
||||||
async deleteWorkspace({ workspaceId }: Jobs['indexer.deleteWorkspace']) {
|
async deleteWorkspace({ workspaceId }: Jobs['indexer.deleteWorkspace']) {
|
||||||
|
if (!this.config.indexer.enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await this.queue.remove(
|
await this.queue.remove(
|
||||||
`indexWorkspace/${workspaceId}`,
|
`indexWorkspace/${workspaceId}`,
|
||||||
'indexer.indexWorkspace'
|
'indexer.indexWorkspace'
|
||||||
@@ -136,6 +152,10 @@ export class IndexerJob {
|
|||||||
|
|
||||||
@OnJob('indexer.autoIndexWorkspaces')
|
@OnJob('indexer.autoIndexWorkspaces')
|
||||||
async autoIndexWorkspaces(payload: Jobs['indexer.autoIndexWorkspaces']) {
|
async autoIndexWorkspaces(payload: Jobs['indexer.autoIndexWorkspaces']) {
|
||||||
|
if (!this.config.indexer.enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const startSid = payload.lastIndexedWorkspaceSid ?? 0;
|
const startSid = payload.lastIndexedWorkspaceSid ?? 0;
|
||||||
const workspaces = await this.models.workspace.listAfterSid(
|
const workspaces = await this.models.workspace.listAfterSid(
|
||||||
startSid,
|
startSid,
|
||||||
|
|||||||
Reference in New Issue
Block a user