-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Statements): Add statement processing priority flag (#824)
- Loading branch information
Showing
29 changed files
with
356 additions
and
52 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
4 changes: 4 additions & 0 deletions
4
src/apps/statements/enums/statementProcessingPriority.enum.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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export enum StatementProcessingPriority { | ||
LOW = 'LOW', | ||
MEDIUM = 'MEDIUM', | ||
} |
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
6 changes: 4 additions & 2 deletions
6
src/apps/statements/expressPresenter/postStatements/storeStatements.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
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
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
17 changes: 17 additions & 0 deletions
17
src/apps/statements/expressPresenter/utils/validateStatementProcessingPriority.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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { createWarning, Warnings } from 'rulr'; | ||
|
||
import { StatementProcessingPriority } from '../../enums/statementProcessingPriority.enum'; | ||
|
||
export const validateStatementProcessingPriority = ( | ||
statementProcessingPriority: string | undefined, | ||
): void | Warnings[] => { | ||
if ( | ||
statementProcessingPriority && | ||
!Object.values(StatementProcessingPriority).includes( | ||
statementProcessingPriority as StatementProcessingPriority, | ||
) | ||
) { | ||
const warnings = [createWarning(statementProcessingPriority, ['query', 'priority'])]; | ||
throw new Warnings({}, ['query'], warnings); | ||
} | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,22 @@ | ||
import { StatementProcessingPriority } from '../../../enums/statementProcessingPriority.enum'; | ||
import { EVENT_NAME } from '../utils/constants'; | ||
import { getPrefixWithProcessingPriority } from '../utils/getPrefixWithProcessingPriority'; | ||
import FacadeConfig from '../utils/redisEvents/FacadeConfig'; | ||
|
||
const EVENT_NAME = 'statement.new'; | ||
|
||
export default (config: FacadeConfig) => { | ||
return async (): Promise<void> => { | ||
const client = await config.client(); | ||
const listName = `${config.prefix}:${EVENT_NAME}`; | ||
await client.del(listName); | ||
|
||
await Promise.all( | ||
Object.values(StatementProcessingPriority).map((statementProcessingPriority) => { | ||
const listName = `${getPrefixWithProcessingPriority( | ||
config.prefix, | ||
statementProcessingPriority, | ||
config.isQueuePriorityEnabled, | ||
)}:${EVENT_NAME}`; | ||
|
||
return client.del(listName); | ||
}), | ||
); | ||
}; | ||
}; |
2 changes: 2 additions & 0 deletions
2
src/apps/statements/repo/eventsRepo/emitNewStatements/Signature.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
18 changes: 12 additions & 6 deletions
18
src/apps/statements/repo/eventsRepo/emitNewStatements/redis.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
Oops, something went wrong.