-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(query-orchestrator): Introduce CubeStoreQueueDriver
- Loading branch information
Showing
20 changed files
with
713 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 52 additions & 14 deletions
66
packages/cubejs-base-driver/src/queue-driver.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,61 @@ | ||
export type QueryDef = unknown; | ||
export type QueryKey = string | [string, any[]]; | ||
|
||
export type AddToQueueResponse = [added: number, _b: any, _c: any, queueSize: number, addedToQueueTime: number]; | ||
export type QueryStageStateResponse = [active: string[], toProcess: string[]] | [active: string[], toProcess: string[], defs: Record<string, QueryDef>]; | ||
export type RetrieveForProcessingResponse = [added: any, removed: any, active: string[], toProcess: any, def: QueryDef, lockAquired: boolean] | null; | ||
|
||
export interface AddToQueueQuery { | ||
isJob: boolean, | ||
orphanedTimeout: unknown | ||
} | ||
|
||
export interface AddToQueueOptions { | ||
stageQueryKey: string, | ||
requestId: string | ||
} | ||
|
||
export interface QueueDriverOptions { | ||
redisQueuePrefix: string, | ||
concurrency: number, | ||
continueWaitTimeout: number, | ||
orphanedTimeout: number, | ||
heartBeatTimeout: number, | ||
getQueueEventsBus?: any, | ||
} | ||
|
||
export interface QueueDriverConnectionInterface { | ||
redisHash(queryKey: QueryKey): string; | ||
getResultBlocking(queryKey: string): Promise<unknown>; | ||
getResult(queryKey: string): Promise<unknown>; | ||
addToQueue(queryKey: string): Promise<unknown>; | ||
getToProcessQueries(): Promise<unknown>; | ||
getActiveQueries(): Promise<unknown>; | ||
getOrphanedQueries(): Promise<unknown>; | ||
getStalledQueries(): Promise<unknown>; | ||
getQueryStageState(onlyKeys: any): Promise<unknown>; | ||
getResult(queryKey: string): Promise<any>; | ||
addToQueue(keyScore: number, queryKey: QueryKey, orphanedTime: any, queryHandler: any, query: AddToQueueQuery, priority: number, options: AddToQueueOptions): Promise<AddToQueueResponse>; | ||
// Return query keys which was sorted by priority and time | ||
getToProcessQueries(): Promise<string[]>; | ||
getActiveQueries(): Promise<string[]>; | ||
getQueryDef(queryKey: string): Promise<QueryDef | null>; | ||
// Queries which was added to queue, but was not processed and not needed | ||
getOrphanedQueries(): Promise<string[]>; | ||
// Queries which was not completed with old heartbeat | ||
getStalledQueries(): Promise<string[]>; | ||
getQueryStageState(onlyKeys: boolean): Promise<QueryStageStateResponse>; | ||
updateHeartBeat(queryKey: string): Promise<void>; | ||
getNextProcessingId(): Promise<string>; | ||
retrieveForProcessing(queryKey: string, processingId: string): Promise<unknown>; | ||
freeProcessingLock(queryKe: string, processingId: string, activated: unknown): Promise<unknown>; | ||
optimisticQueryUpdate(queryKey, toUpdate, processingId): Promise<unknown>; | ||
cancelQuery(queryKey: string): Promise<unknown>; | ||
getNextProcessingId(): Promise<string | number>; | ||
// Trying to acquire a lock for processing a queue item, this method can return null when | ||
// multiple nodes tries to process the same query | ||
retrieveForProcessing(queryKey: string, processingId: number | string): Promise<RetrieveForProcessingResponse>; | ||
freeProcessingLock(queryKe: string, processingId: string | number, activated: unknown): Promise<void>; | ||
optimisticQueryUpdate(queryKey, toUpdate, processingId): Promise<boolean>; | ||
cancelQuery(queryKey: string): Promise<[QueryDef]>; | ||
getQueryAndRemove(queryKey: string): Promise<[QueryDef]>; | ||
setResultAndRemoveQuery(queryKey: string, executionResult: any, processingId: any): Promise<unknown>; | ||
release(): Promise<void>; | ||
release(): void; | ||
// | ||
getQueriesToCancel(): Promise<string[]> | ||
getActiveAndToProcess(): Promise<[active: string[], toProcess: string[]]>; | ||
} | ||
|
||
export interface QueueDriverInterface { | ||
redisHash(queryKey: QueryKey): string; | ||
createConnection(): Promise<QueueDriverConnectionInterface>; | ||
release(connection: QueueDriverConnectionInterface): Promise<void>; | ||
release(connection: QueueDriverConnectionInterface): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.