mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-03 02:20:19 +08:00
feat(infra): job system (#7212)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import type { Observable } from 'rxjs';
|
||||
|
||||
export interface JobParams<Payload = any> {
|
||||
batchKey: string;
|
||||
payload: Payload;
|
||||
}
|
||||
|
||||
export interface Job<Payload = any> extends JobParams<Payload> {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface JobQueueStatus {
|
||||
remaining: number;
|
||||
}
|
||||
|
||||
export interface JobQueue<Payload> {
|
||||
enqueue(jobs: JobParams<Payload>[]): Promise<void>;
|
||||
|
||||
accept(): Promise<Job<Payload>[] | null>;
|
||||
|
||||
waitForAccept(signal: AbortSignal): Promise<Job<Payload>[]>;
|
||||
|
||||
return(jobs: Job<Payload>[], retry?: boolean): Promise<void>;
|
||||
|
||||
clear(): Promise<void>;
|
||||
|
||||
status$: Observable<JobQueueStatus>;
|
||||
}
|
||||
Reference in New Issue
Block a user