mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-04 19:15:33 +08:00
d975bf46fb
#### PR Dependency Tree * **PR #14783** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Configurable request timeout for calendar integrations. * Calendar polling now enqueues per-subscription sync jobs (larger batch) for improved throughput. * **Bug Fixes / Improvements** * Persisted next-sync timestamps and retry counts for more reliable scheduling and retry behavior. * Exponential backoff and webhook renewal now update scheduling consistently. * **Refactor** * Calendar sync flow moved to a job-queue-driven design for better concurrency and observability. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
98 lines
2.0 KiB
TypeScript
98 lines
2.0 KiB
TypeScript
import { DefaultJobOptions, WorkerOptions } from 'bullmq';
|
|
|
|
import { defineModuleConfig, JSONSchema } from '../../config';
|
|
import { Queue } from './def';
|
|
|
|
declare global {
|
|
interface AppConfigSchema {
|
|
job: {
|
|
queue: ConfigItem<Omit<DefaultJobOptions, 'connection' | 'telemetry'>>;
|
|
worker: ConfigItem<Omit<WorkerOptions, 'connection' | 'telemetry'>>;
|
|
queues: {
|
|
[key in Queue]: ConfigItem<{
|
|
concurrency: number;
|
|
}>;
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
const schema: JSONSchema = {
|
|
type: 'object',
|
|
properties: {
|
|
concurrency: { type: 'number' },
|
|
},
|
|
};
|
|
|
|
defineModuleConfig('job', {
|
|
queue: {
|
|
desc: 'The config for job queues',
|
|
default: {
|
|
attempts: 5,
|
|
// retry after 2 ^ (attempts - 1) * delay milliseconds
|
|
backoff: { type: 'exponential', delay: 1000 },
|
|
// should remove job after it's completed, because we will add a new job with the same job id
|
|
removeOnComplete: true,
|
|
removeOnFail: {
|
|
age: 24 * 3600 /* 1 day */,
|
|
count: 500,
|
|
},
|
|
},
|
|
link: 'https://api.docs.bullmq.io/interfaces/v5.QueueOptions.html',
|
|
},
|
|
|
|
worker: {
|
|
desc: 'The config for job workers',
|
|
default: {},
|
|
link: 'https://api.docs.bullmq.io/interfaces/v5.WorkerOptions.html',
|
|
},
|
|
|
|
'queues.copilot': {
|
|
desc: 'The config for copilot job queue',
|
|
default: {
|
|
concurrency: 10,
|
|
},
|
|
schema,
|
|
},
|
|
|
|
'queues.calendar': {
|
|
desc: 'The config for calendar job queue',
|
|
default: {
|
|
concurrency: 4,
|
|
},
|
|
schema,
|
|
},
|
|
|
|
'queues.doc': {
|
|
desc: 'The config for doc job queue',
|
|
default: {
|
|
concurrency: 1,
|
|
},
|
|
schema,
|
|
},
|
|
|
|
'queues.indexer': {
|
|
desc: 'The config for indexer job queue',
|
|
default: {
|
|
concurrency: 1,
|
|
},
|
|
schema,
|
|
},
|
|
|
|
'queues.notification': {
|
|
desc: 'The config for notification job queue',
|
|
default: {
|
|
concurrency: 10,
|
|
},
|
|
schema,
|
|
},
|
|
|
|
'queues.nightly': {
|
|
desc: 'The config for nightly job queue',
|
|
default: {
|
|
concurrency: 1,
|
|
},
|
|
schema,
|
|
},
|
|
});
|