backend: Refactor S3 service to use internal configuration for retry settings

This commit is contained in:
Carlos Santos 2025-05-07 11:54:13 +02:00
parent a5024fccf2
commit 39b53f537d
3 changed files with 7 additions and 10 deletions

View File

@ -15,11 +15,13 @@ const INTERNAL_CONFIG = {
// Headers for API requests
API_KEY_HEADER: 'x-api-key',
// Fixed usernames
// Authentication usernames
ANONYMOUS_USER: 'anonymous',
API_USER: 'api-user',
// S3 prefixes
// S3 configuration
S3_MAX_RETRIES_ATTEMPTS_ON_SAVE_ERROR: '5',
S3_INITIAL_RETRY_DELAY_MS: '100',
S3_ROOMS_PREFIX: 'rooms',
S3_RECORDINGS_PREFIX: 'recordings',

View File

@ -54,8 +54,6 @@ export const {
MEET_S3_SECRET_KEY = 'minioadmin',
MEET_AWS_REGION = 'us-east-1',
MEET_S3_WITH_PATH_STYLE_ACCESS = 'true',
MEET_S3_MAX_RETRIES_ATTEMPTS_ON_SAVE_ERROR = '5',
MEET_S3_INITIAL_RETRY_DELAY_MS = '100',
// Redis configuration
MEET_REDIS_HOST: REDIS_HOST = 'localhost',
@ -126,8 +124,6 @@ export const logEnvVars = () => {
console.log('MEET S3 SECRET KEY:', credential('****' + MEET_S3_SECRET_KEY.slice(-3)));
console.log('MEET AWS REGION:', text(MEET_AWS_REGION));
console.log('MEET S3 WITH PATH STYLE ACCESS:', text(MEET_S3_WITH_PATH_STYLE_ACCESS));
console.log('MEET S3 MAX RETRIES ATTEMPTS ON SAVE ERROR:', text(MEET_S3_MAX_RETRIES_ATTEMPTS_ON_SAVE_ERROR));
console.log('MEET S3 INITIAL RETRY DELAY MS:', text(MEET_S3_INITIAL_RETRY_DELAY_MS));
console.log('---------------------------------------------------------');
console.log('Redis Configuration');
console.log('---------------------------------------------------------');

View File

@ -18,8 +18,6 @@ import {
MEET_AWS_REGION,
MEET_S3_ACCESS_KEY,
MEET_S3_BUCKET,
MEET_S3_INITIAL_RETRY_DELAY_MS,
MEET_S3_MAX_RETRIES_ATTEMPTS_ON_SAVE_ERROR,
MEET_S3_SECRET_KEY,
MEET_S3_SERVICE_ENDPOINT,
MEET_S3_SUBBUCKET,
@ -27,6 +25,7 @@ import {
} from '../environment.js';
import { errorS3NotAvailable, internalError } from '../models/error.model.js';
import { LoggerService } from './index.js';
import INTERNAL_CONFIG from '../config/internal-config.js';
@injectable()
export class S3Service {
@ -280,8 +279,8 @@ export class S3Service {
*/
protected async retryOperation<T>(operation: () => Promise<T>): Promise<T> {
let attempt = 0;
let delayMs = Number(MEET_S3_INITIAL_RETRY_DELAY_MS);
const maxRetries = Number(MEET_S3_MAX_RETRIES_ATTEMPTS_ON_SAVE_ERROR);
let delayMs = Number(INTERNAL_CONFIG.S3_INITIAL_RETRY_DELAY_MS);
const maxRetries = Number(INTERNAL_CONFIG.S3_MAX_RETRIES_ATTEMPTS_ON_SAVE_ERROR);
while (true) {
try {