Skip to content

Commit

Permalink
health check
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoch05 committed Aug 21, 2024
1 parent c6cda94 commit 70d2f23
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions apollo/src/aggregation/aggregation.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,11 @@ export class AggregationResolver {
@Query()
tasksHealthCheck(@Args('name') name: string) {
const healthChecks = this.aggregationService.tasksHealthCheck();
if (name !== null) {
if (name) {
return [
{
name: name,
callTimes: healthChecks[name],
callTimes: healthChecks.get(name),
},
];
}
Expand Down
1 change: 1 addition & 0 deletions apollo/src/base/TransferServiceT1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export abstract class BaseServiceT1 {
this.baseConfigure.fetchSendDataInterval,
async () => {
this.schedule(item, index);
return false;
}
);
});
Expand Down
2 changes: 2 additions & 0 deletions apollo/src/lnv2/lnv2.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export class Lnv2Service implements OnModuleInit {
index: 2 * index,
};
this.schedule(item, indexInfo);
return false;
}
);
}
Expand All @@ -103,6 +104,7 @@ export class Lnv2Service implements OnModuleInit {
index: 2 * index + 1,
};
this.schedule(item, indexInfo);
return false;
}
);
}
Expand Down
3 changes: 2 additions & 1 deletion apollo/src/lnv3/lnv3.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class Lnv3Service implements OnModuleInit {
this.fetchSendDataInterval,
async () => {
if (this.fetchCache[index].isSyncingHistory) {
return;
return true;
}
this.fetchCache[index].isSyncingHistory = true;
await this.fetchProviderInfo(item, index);
Expand All @@ -66,6 +66,7 @@ export class Lnv3Service implements OnModuleInit {
await this.fetchStatus(item, index);
await this.fetchWithdrawCacheStatus(item, index);
this.fetchCache[index].isSyncingHistory = false;
return false;
}
);
});
Expand Down
12 changes: 6 additions & 6 deletions apollo/src/lnv3/source/super.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class Lnv3SuperService extends SourceService {
.post(url, {
query: query,
variables: null,
})
}, { timeout: 10000 })
.then((res) => res.data?.data?.lnv3TransferRecords);
}

Expand All @@ -28,7 +28,7 @@ export class Lnv3SuperService extends SourceService {
.post(url, {
query: query,
variables: null,
})
}, { timeout: 10000 })
.then((res) => res.data?.data?.lnv3RelayUpdateRecords);
}
async queryRelayStatus(
Expand All @@ -41,7 +41,7 @@ export class Lnv3SuperService extends SourceService {
.post(url, {
query: query,
variables: null,
})
}, { timeout: 10000 })
.then((res) => res.data?.data?.lnv3RelayRecord);
}
async queryMultiRelayStatus(
Expand All @@ -55,7 +55,7 @@ export class Lnv3SuperService extends SourceService {
.post(url, {
query: query,
variables: null,
})
}, { timeout: 10000 })
.then((res) => res.data?.data?.lnv3RelayRecords);
}
async batchQueryRelayStatus(
Expand All @@ -69,7 +69,7 @@ export class Lnv3SuperService extends SourceService {
.post(url, {
query: query,
variables: null,
})
}, { timeout: 10000 })
.then((res) => res.data?.data?.lnv3RelayRecords);
}
async queryWithdrawStatus(
Expand All @@ -82,7 +82,7 @@ export class Lnv3SuperService extends SourceService {
.post(url, {
query: query,
variables: null,
})
}, { timeout: 10000 })
.then((res) => res.data?.data?.lnv3TransferRecord);
}
}
8 changes: 5 additions & 3 deletions apollo/src/tasks/tasks.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ export class TasksService {

constructor(private schedulerRegistry: SchedulerRegistry) {}

addInterval(name: string, milliseconds: number, callback: () => void) {
addInterval(name: string, milliseconds: number, callback: () => Promise<boolean>) {
this.logger.log(`new interval task added name:${name}, ms: ${milliseconds}`);
this.healthChecks.set(name, 0);
const interval = setInterval(async () => {
const callTimes: number = this.healthChecks.get(name);
await callback();
this.healthChecks.set(name, callTimes + 1);
const busy = await callback();
if (!busy) {
this.healthChecks.set(name, callTimes + 1);
}
}, milliseconds);
this.schedulerRegistry.addInterval(name, interval);
}
Expand Down

0 comments on commit 70d2f23

Please sign in to comment.