Skip to content

Commit 2a1c541

Browse files
committed
refactor(database): database connection and message service code with minor changes
1 parent e944386 commit 2a1c541

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/service/database/ServiceProvider.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class ServiceProvider {
1515
this._clientInstance = new Client();
1616
}
1717

18-
static async initialize(): Promise<ServiceProvider|null> {
18+
static async initialize(): Promise<ServiceProvider | null> {
1919
if (!ServiceProvider.instance) {
2020
const instance = new ServiceProvider();
2121
const isInitialized = await instance._clientInstance.initialize();
@@ -85,21 +85,18 @@ export class ServiceProvider {
8585

8686
for (let attempt = 0; attempt < retries; attempt++) {
8787
try {
88-
logger.warn(`Database connection attempt ${attempt + 1}...`, 'Database');
89-
return await fn(); // Try executing the provided function
88+
return await fn();
9089
} catch (error: any) {
9190
lastError = error;
9291
logger.warn(`Retry Attempt ${attempt + 1} failed with error: ${error.message || error}.`, 'Database');
93-
9492
if (attempt < retries - 1) {
95-
const backoffTime = delay * Math.pow(2, attempt); // Exponential backoff
93+
const backoffTime = delay * Math.pow(2, attempt);
9694
logger.warn(`Retrying in ${backoffTime}ms...`, 'Database');
9795
await new Promise((res) => setTimeout(res, backoffTime));
9896
}
9997
}
10098
}
101-
10299
logger.error(`All ${retries} retry attempts failed. Last error: ${lastError?.message || lastError}`, 'Database');
103-
return null; // Return null if all retries fail
100+
return null;
104101
}
105102
}

src/service/messages/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export class MessagesService {
1313
}
1414
private isText(): boolean {
1515
if (!this._ctx.message?.text) {
16-
logger.warn('Message text is undefined');
1716
return false;
1817
}
1918
return true;

0 commit comments

Comments
 (0)