Skip to content

Commit 16e1406

Browse files
author
Ihar
committed
refactor code
1 parent feee47e commit 16e1406

File tree

2 files changed

+1
-10
lines changed

2 files changed

+1
-10
lines changed

common/src/mq/nats-service.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ export abstract class NatsService {
212212
* @param noRespond
213213
*/
214214
public getMessages<T, A>(subject: string, cb: Function, noRespond = false): Subscription {
215-
const sub = this.connection.subscribe(subject, {
215+
return this.connection.subscribe(subject, {
216216
queue: this.messageQueueName,
217217
callback: async (error, msg) => {
218218
try {
@@ -236,7 +236,5 @@ export abstract class NatsService {
236236
}
237237
}
238238
});
239-
240-
return sub;
241239
}
242240
}

worker-service/src/api/worker.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ function logMemoryUsage(label: string) {
2828
function rejectTimeout(t: number): Promise<void> {
2929
return new Promise((_, reject) => {
3030
setTimeout(() => {
31-
console.log(`⏳ Timeout reached after ${t}ms`);
3231
reject(new Error('Timeout error'));
3332
}, t);
3433
})
@@ -165,8 +164,6 @@ export class Worker extends NatsService {
165164
}
166165

167166
this.subscribe(WorkerEvents.GET_FREE_WORKERS, async (msg) => {
168-
// console.log('this.replySubject worker init', this.replySubject)
169-
// console.log('msg.replySubject worker init', msg.replySubject)
170167
if (!this.isInUse) {
171168
this.publish(msg.replySubject, {
172169
subject: [this.replySubject, WorkerEvents.SEND_TASK_TO_WORKER].join('.'),
@@ -311,9 +308,7 @@ export class Worker extends NatsService {
311308
if (!task.data.payload || !task.data.payload.cid || !task.data.payload.responseType) {
312309
result.error = 'Invalid CID';
313310
} else {
314-
logMemoryUsage('Before IPFS File Fetch');
315311
let fileContent = await this.ipfsClient.getFile(task.data.payload.cid);
316-
logMemoryUsage('After IPFS File Fetch');
317312
if (fileContent instanceof Buffer) {
318313
const data = await this.channel.request<any, any>(ExternalMessageEvents.IPFS_AFTER_READ_CONTENT, {
319314
responseType: !task.data.payload.responseType,
@@ -1001,12 +996,10 @@ export class Worker extends NatsService {
1001996
private processTaskWithTimeout(task: ITask): Promise<ITaskResult> {
1002997
return new Promise(async (resolve, reject) => {
1003998
try {
1004-
logMemoryUsage('Before Processing Task');
1005999
const result = await Promise.race([
10061000
this.processTask(task),
10071001
rejectTimeout(this.taskTimeout)
10081002
]);
1009-
logMemoryUsage('After Processing Task');
10101003
resolve(result as ITaskResult);
10111004
} catch (e) {
10121005
const error = {

0 commit comments

Comments
 (0)