Skip to content

Commit 6e92456

Browse files
committed
feat: Add support of ENABLE_QUEUE_PRIORITY env variable to events repo
1 parent b22acbe commit 6e92456

8 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/apps/statements/repo/eventsRepo/FactoryConfig.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ import RedisFactoryConfig from './utils/redisEvents/FactoryConfig';
33
export default interface FactoryConfig {
44
readonly facade?: string;
55
readonly redis?: RedisFactoryConfig;
6+
readonly isQueuePriorityEnabled?: boolean;
67
}

src/apps/statements/repo/eventsRepo/clearRepo/redis.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default (config: FacadeConfig) => {
1212
const listName = `${getPrefixWithProcessingPriority(
1313
config.prefix,
1414
statementProcessingPriority,
15+
config.isQueuePriorityEnabled,
1516
)}:${EVENT_NAME}`;
1617

1718
return client.del(listName);

src/apps/statements/repo/eventsRepo/emitNewStatements/redis.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ export default (config: FacadeConfig): Signature => {
77
return async ({ statementProperties, priority }) => {
88
const client = await config.client();
99

10-
const prefixWithPriority = getPrefixWithProcessingPriority(config.prefix, priority);
10+
const prefixWithPriority = getPrefixWithProcessingPriority(
11+
config.prefix,
12+
priority,
13+
config.isQueuePriorityEnabled,
14+
);
1115
const listName = `${prefixWithPriority}:${EVENT_NAME}`;
1216
const channelName = `${prefixWithPriority}:${CHANNEL_NAME}`;
1317

src/apps/statements/repo/eventsRepo/utils/redisEvents/FacadeConfig.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ import { Redis } from 'ioredis';
33
export default interface FacadeConfig {
44
readonly client: () => Promise<Redis>;
55
readonly prefix: string;
6+
readonly isQueuePriorityEnabled: boolean;
67
}

src/apps/statements/repo/eventsRepo/utils/redisEvents/FactoryConfig.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ import { Redis } from 'ioredis';
33
export default interface FactoryConfig {
44
readonly client?: () => Promise<Redis>;
55
readonly prefix?: string;
6+
readonly isQueuePriorityEnabled?: boolean;
67
}

src/apps/statements/repo/eventsRepo/utils/redisEvents/factory.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default (factoryConfig: FactoryConfig = {}): Facade => {
1010
const facadeConfig: FacadeConfig = {
1111
client: defaultTo(factoryConfig.client, connectToRedis()),
1212
prefix: defaultTo(factoryConfig.prefix, 'xapistatements'),
13+
isQueuePriorityEnabled: defaultTo(factoryConfig.isQueuePriorityEnabled, false),
1314
};
1415
return {
1516
emitNewStatements: emitNewStatements(facadeConfig),

src/apps/statements/repo/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const repo: Repo = factory({
1818
client: connectToRedis(),
1919
prefix: config.redis.prefix,
2020
},
21+
isQueuePriorityEnabled: config.isQueuePriorityEnabled,
2122
},
2223
models: {
2324
facade: config.repoFactory.modelsRepoName,

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const mongoUrl = getStringOption(process.env.MONGO_URL, defaultMongoUrl);
2727

2828
export default {
2929
defaultTimeout: getNumberOption(process.env.DEFAULT_TIMEOUT_MS, DEFAULT_TIMEOUT_MS),
30+
isQueuePriorityEnabled: process.env.ENABLE_QUEUE_PRIORITY === 'true',
3031
express: {
3132
allowFormBody: getBooleanOption(process.env.EXPRESS_ALLOW_FORM_BODY, false),
3233
allowUndefinedMethod: getBooleanOption(process.env.EXPRESS_ALLOW_UNDEFINED_METHOD, false),

0 commit comments

Comments
 (0)