Skip to content

Commit

Permalink
Merge pull request #237 from sotatek-dev/feat/add-token
Browse files Browse the repository at this point in the history
feat: job priority
  • Loading branch information
Sotatek-TanHoang authored Jan 7, 2025
2 parents 95506af + f6271f3 commit 95ba5c5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/constants/queue.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ export enum EQueueName {
}
export const getEvmValidatorQueueName = (index: number) => `EVM_VALIDATOR_${index}`;
export const getMinaValidatorQueueName = (index: number) => `MINA_VALIDATOR_${index}`;

// job priority, lower index is higher priority
export enum EJobPriority {
DEPLOY_TOKEN,
UNLOCK,
}
10 changes: 8 additions & 2 deletions src/modules/crawler/deploy-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { IsNull } from 'typeorm';

import { ETokenPairStatus } from '../../constants/blockchain.constant.js';
import { EEnvKey } from '../../constants/env.constant.js';
import { EQueueName } from '../../constants/queue.constant.js';
import { EJobPriority, EQueueName } from '../../constants/queue.constant.js';
import { CommonConfigRepository } from '../../database/repositories/common-configuration.repository.js';
import { LoggerService } from '../../shared/modules/logger/logger.service.js';
import { QueueService } from '../../shared/modules/queue/queue.service.js';
Expand Down Expand Up @@ -148,6 +148,7 @@ export class TokenDeployer {
jobId: `deploy-token-${tokenPairId}`,
removeOnComplete: true,
removeOnFail: true,
priority: EJobPriority.DEPLOY_TOKEN,
},
);
}
Expand All @@ -160,7 +161,12 @@ export class TokenDeployer {
tokenPairId,
},
},
{ jobId: `deploy-token-${tokenPairId}`, removeOnComplete: true, removeOnFail: true },
{
jobId: `deploy-token-${tokenPairId}`,
removeOnComplete: true,
removeOnFail: true,
priority: EJobPriority.DEPLOY_TOKEN,
},
);
}
}
8 changes: 7 additions & 1 deletion src/modules/crawler/job-unlock.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import { QueryDeepPartialEntity } from 'typeorm/query-builder/QueryPartialEntity

import { ENetworkName } from '../../constants/blockchain.constant.js';
import { EEnvKey } from '../../constants/env.constant.js';
import { EQueueName, getEvmValidatorQueueName, getMinaValidatorQueueName } from '../../constants/queue.constant.js';
import {
EJobPriority,
EQueueName,
getEvmValidatorQueueName,
getMinaValidatorQueueName,
} from '../../constants/queue.constant.js';
import { CommonConfigRepository } from '../../database/repositories/common-configuration.repository.js';
import { EventLogRepository } from '../../database/repositories/event-log.repository.js';
import { LoggerService } from '../../shared/modules/logger/logger.service.js';
Expand Down Expand Up @@ -188,6 +193,7 @@ export class JobUnlockProvider {
jobId: `send-unlock-${data.eventLogId}`,
removeOnComplete: true,
removeOnFail: true,
priority: EJobPriority.UNLOCK,
},
);
}
Expand Down
1 change: 1 addition & 0 deletions src/modules/users/admin.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class AdminService {
newCommonConfig.mintingFee = payload.mintingFee;
newCommonConfig.unlockingFee = payload.unlockingFee;
newCommonConfig.status = ETokenPairStatus.CREATED;
newCommonConfig.isHidden = true;
return newCommonConfig.save();
});
assert(isNumber(newTokenPair.id), 'Token pair invalid!');
Expand Down

0 comments on commit 95ba5c5

Please sign in to comment.