Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Feature/expose portfolio snapshot computation timeout as environment variable (#3894)
ceromac44da0bce393
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d83247b12b..84b641513f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Changed+- Exposed the timeout of the portfolio snapshot computation as an environment variable (`PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_TIMEOUT`)- Improved the portfolio unit tests to work with exported activity files### Fixeddiff --git a/apps/api/src/services/configuration/configuration.service.ts b/apps/api/src/services/configuration/configuration.service.tsindex cca393a2aa..dafd4803c3 100644--- a/apps/api/src/services/configuration/configuration.service.ts+++ b/apps/api/src/services/configuration/configuration.service.ts@@ -4,6 +4,7 @@ import {DEFAULT_PROCESSOR_CONCURRENCY_GATHER_ASSET_PROFILE,DEFAULT_PROCESSOR_CONCURRENCY_GATHER_HISTORICAL_MARKET_DATA,DEFAULT_PROCESSOR_CONCURRENCY_PORTFOLIO_SNAPSHOT,+ DEFAULT_PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_TIMEOUT,DEFAULT_ROOT_URL} from '@ghostfolio/common/config';@@ -59,6 +60,9 @@ export class ConfigurationService {PROCESSOR_CONCURRENCY_PORTFOLIO_SNAPSHOT: num({default: DEFAULT_PROCESSOR_CONCURRENCY_PORTFOLIO_SNAPSHOT}),+ PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_TIMEOUT: num({+ default: DEFAULT_PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_TIMEOUT+ }),REDIS_DB: num({ default: 0 }),REDIS_HOST: str({ default: 'localhost' }),REDIS_PASSWORD: str({ default: '' }),diff --git a/apps/api/src/services/queues/portfolio-snapshot/portfolio-snapshot.module.ts b/apps/api/src/services/queues/portfolio-snapshot/portfolio-snapshot.module.tsindex 620feda53a..058d971d88 100644--- a/apps/api/src/services/queues/portfolio-snapshot/portfolio-snapshot.module.ts+++ b/apps/api/src/services/queues/portfolio-snapshot/portfolio-snapshot.module.ts@@ -8,7 +8,10 @@ import { DataProviderModule } from '@ghostfolio/api/services/data-provider/data-import { ExchangeRateDataModule } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.module';import { MarketDataModule } from '@ghostfolio/api/services/market-data/market-data.module';import { PortfolioSnapshotService } from '@ghostfolio/api/services/queues/portfolio-snapshot/portfolio-snapshot.service';-import { PORTFOLIO_SNAPSHOT_QUEUE } from '@ghostfolio/common/config';+import {+ DEFAULT_PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_TIMEOUT,+ PORTFOLIO_SNAPSHOT_QUEUE+} from '@ghostfolio/common/config';import { BullModule } from '@nestjs/bull';import { Module } from '@nestjs/common';@@ -20,7 +23,14 @@ import { PortfolioSnapshotProcessor } from './portfolio-snapshot.processor';imports: [AccountBalanceModule,BullModule.registerQueue({- name: PORTFOLIO_SNAPSHOT_QUEUE+ name: PORTFOLIO_SNAPSHOT_QUEUE,+ settings: {+ lockDuration: parseInt(+ process.env.PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_TIMEOUT ??+ DEFAULT_PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_TIMEOUT.toString(),+ 10+ )+ }}),ConfigurationModule,DataProviderModule,diff --git a/libs/common/src/lib/config.ts b/libs/common/src/lib/config.tsindex 19ec965fa0..4a5079d283 100644--- a/libs/common/src/lib/config.ts+++ b/libs/common/src/lib/config.ts@@ -51,6 +51,7 @@ export const DEFAULT_PAGE_SIZE = 50;export const DEFAULT_PROCESSOR_CONCURRENCY_GATHER_ASSET_PROFILE = 1;export const DEFAULT_PROCESSOR_CONCURRENCY_GATHER_HISTORICAL_MARKET_DATA = 1;export const DEFAULT_PROCESSOR_CONCURRENCY_PORTFOLIO_SNAPSHOT = 1;+export const DEFAULT_PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_TIMEOUT = 30000;export const DEFAULT_ROOT_URL = 'https://localhost:4200';// USX is handled separately