log queue name

This commit is contained in:
boufni95 2024-02-23 17:14:47 +01:00
parent 02db6f030c
commit 9f3e2473e3
3 changed files with 7 additions and 6 deletions

View file

@ -25,10 +25,10 @@ export default class {
constructor(settings: StorageSettings) { constructor(settings: StorageSettings) {
this.settings = settings this.settings = settings
} }
async Connect(migrations: Function[], metricsMigrations: Function []) { async Connect(migrations: Function[], metricsMigrations: Function[]) {
const { source, executedMigrations } = await NewDB(this.settings.dbSettings, migrations) const { source, executedMigrations } = await NewDB(this.settings.dbSettings, migrations)
this.DB = source this.DB = source
this.txQueue = new TransactionsQueue(this.DB) this.txQueue = new TransactionsQueue("main", this.DB)
this.userStorage = new UserStorage(this.DB, this.txQueue) this.userStorage = new UserStorage(this.DB, this.txQueue)
this.productStorage = new ProductStorage(this.DB, this.txQueue) this.productStorage = new ProductStorage(this.DB, this.txQueue)
this.applicationStorage = new ApplicationStorage(this.DB, this.userStorage, this.txQueue) this.applicationStorage = new ApplicationStorage(this.DB, this.userStorage, this.txQueue)

View file

@ -15,7 +15,7 @@ export default class {
async Connect(metricsMigrations: Function[]) { async Connect(metricsMigrations: Function[]) {
const { source, executedMigrations } = await newMetricsDb(this.settings.dbSettings, metricsMigrations) const { source, executedMigrations } = await newMetricsDb(this.settings.dbSettings, metricsMigrations)
this.DB = source; this.DB = source;
this.txQueue = new TransactionsQueue(this.DB) this.txQueue = new TransactionsQueue("metrics", this.DB)
return executedMigrations; return executedMigrations;
} }
async SaveRoutingEvent(event: Partial<RoutingEvent>) { async SaveRoutingEvent(event: Partial<RoutingEvent>) {

View file

@ -1,5 +1,5 @@
import { DataSource, EntityManager, EntityTarget } from "typeorm" import { DataSource, EntityManager, EntityTarget } from "typeorm"
import { getLogger } from "../helpers/logger.js" import { PubLogger, getLogger } from "../helpers/logger.js"
export type TX<T> = (entityManager: EntityManager | DataSource) => Promise<T> export type TX<T> = (entityManager: EntityManager | DataSource) => Promise<T>
export type TxOperation<T> = { export type TxOperation<T> = {
@ -11,9 +11,10 @@ export default class {
DB: DataSource | EntityManager DB: DataSource | EntityManager
pendingTx: boolean pendingTx: boolean
transactionsQueue: { op: TxOperation<any>, res: (v: any) => void, rej: (message: string) => void }[] = [] transactionsQueue: { op: TxOperation<any>, res: (v: any) => void, rej: (message: string) => void }[] = []
log = getLogger({}) log: PubLogger
constructor(DB: DataSource | EntityManager) { constructor(name: string, DB: DataSource | EntityManager) {
this.DB = DB this.DB = DB
this.log = getLogger({ appName: name })
} }
PushToQueue<T>(op: TxOperation<T>) { PushToQueue<T>(op: TxOperation<T>) {