|
@ -1,5 +1,8 @@ |
|
|
|
|
|
import { RedisCacheService } from '@ghostfolio/api/app/redis-cache/redis-cache.service'; |
|
|
import { DataEnhancerService } from '@ghostfolio/api/services/data-provider/data-enhancer/data-enhancer.service'; |
|
|
import { DataEnhancerService } from '@ghostfolio/api/services/data-provider/data-enhancer/data-enhancer.service'; |
|
|
import { DataProviderService } from '@ghostfolio/api/services/data-provider/data-provider.service'; |
|
|
import { DataProviderService } from '@ghostfolio/api/services/data-provider/data-provider.service'; |
|
|
|
|
|
import { PropertyService } from '@ghostfolio/api/services/property/property.service'; |
|
|
|
|
|
import { PROPERTY_CURRENCIES } from '@ghostfolio/common/config'; |
|
|
|
|
|
|
|
|
import { Injectable } from '@nestjs/common'; |
|
|
import { Injectable } from '@nestjs/common'; |
|
|
import { DataSource } from '@prisma/client'; |
|
|
import { DataSource } from '@prisma/client'; |
|
@ -8,7 +11,9 @@ import { DataSource } from '@prisma/client'; |
|
|
export class HealthService { |
|
|
export class HealthService { |
|
|
public constructor( |
|
|
public constructor( |
|
|
private readonly dataEnhancerService: DataEnhancerService, |
|
|
private readonly dataEnhancerService: DataEnhancerService, |
|
|
private readonly dataProviderService: DataProviderService |
|
|
private readonly dataProviderService: DataProviderService, |
|
|
|
|
|
private readonly propertyService: PropertyService, |
|
|
|
|
|
private readonly redisCacheService: RedisCacheService |
|
|
) {} |
|
|
) {} |
|
|
|
|
|
|
|
|
public async hasResponseFromDataEnhancer(aName: string) { |
|
|
public async hasResponseFromDataEnhancer(aName: string) { |
|
@ -18,4 +23,24 @@ export class HealthService { |
|
|
public async hasResponseFromDataProvider(aDataSource: DataSource) { |
|
|
public async hasResponseFromDataProvider(aDataSource: DataSource) { |
|
|
return this.dataProviderService.checkQuote(aDataSource); |
|
|
return this.dataProviderService.checkQuote(aDataSource); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async isDatabaseHealthy() { |
|
|
|
|
|
try { |
|
|
|
|
|
await this.propertyService.getByKey(PROPERTY_CURRENCIES); |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
} catch { |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async isRedisCacheHealthy() { |
|
|
|
|
|
try { |
|
|
|
|
|
const isHealthy = await this.redisCacheService.isHealthy(); |
|
|
|
|
|
|
|
|
|
|
|
return isHealthy; |
|
|
|
|
|
} catch { |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|