moved folders around
This commit is contained in:
parent
4f89affc2b
commit
36cb84b343
202 changed files with 1160 additions and 660 deletions
|
|
@ -1,11 +1,11 @@
|
|||
import { getDatabaseConfig } from '@stock-bot/config';
|
||||
import { getDatabaseConfig, getQueueConfig } from '@stock-bot/config';
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
import {
|
||||
ConnectionFactory,
|
||||
ServiceContainer,
|
||||
PoolSizeCalculator
|
||||
} from '@stock-bot/connection-factory';
|
||||
import type { ConnectionFactoryConfig, DynamicPoolConfig } from '@stock-bot/mongodb-client';
|
||||
} from '@stock-bot/di';
|
||||
import type { ConnectionFactoryConfig, DynamicPoolConfig } from '@stock-bot/mongodb';
|
||||
|
||||
const logger = getLogger('database-setup');
|
||||
|
||||
|
|
@ -27,6 +27,9 @@ export function createConnectionFactory(): ConnectionFactory {
|
|||
},
|
||||
cache: {
|
||||
poolSize: 20,
|
||||
},
|
||||
queue: {
|
||||
poolSize: 1, // QueueManager is a singleton
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -42,6 +45,7 @@ export async function setupServiceContainer(): Promise<ServiceContainer> {
|
|||
|
||||
const connectionFactory = createConnectionFactory();
|
||||
const dbConfig = getDatabaseConfig();
|
||||
const queueConfig = getQueueConfig();
|
||||
|
||||
// Create base container
|
||||
const container = new ServiceContainer('data-ingestion');
|
||||
|
|
@ -130,6 +134,45 @@ export async function setupServiceContainer(): Promise<ServiceContainer> {
|
|||
singleton: true,
|
||||
});
|
||||
|
||||
// Register QueueManager
|
||||
container.register({
|
||||
name: 'queue',
|
||||
factory: () => {
|
||||
const pool = connectionFactory.createQueue({
|
||||
name: 'default',
|
||||
config: {
|
||||
redis: queueConfig?.redis || {
|
||||
host: dbConfig.dragonfly.host,
|
||||
port: dbConfig.dragonfly.port,
|
||||
db: dbConfig.dragonfly.db || 1,
|
||||
},
|
||||
defaultQueueOptions: {
|
||||
defaultJobOptions: queueConfig?.defaultJobOptions || {
|
||||
attempts: 3,
|
||||
backoff: {
|
||||
type: 'exponential',
|
||||
delay: 1000,
|
||||
},
|
||||
removeOnComplete: 10,
|
||||
removeOnFail: 5,
|
||||
},
|
||||
workers: 2,
|
||||
concurrency: 1,
|
||||
enableMetrics: true,
|
||||
enableDLQ: true,
|
||||
},
|
||||
enableScheduledJobs: true,
|
||||
delayWorkerStart: true,
|
||||
}
|
||||
});
|
||||
return pool.client;
|
||||
},
|
||||
singleton: true,
|
||||
dispose: async (queueManager) => {
|
||||
await queueManager.shutdown();
|
||||
}
|
||||
});
|
||||
|
||||
// Register the connection factory itself for pool management
|
||||
container.register({
|
||||
name: 'connectionFactory',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue