di-refactor coming along
This commit is contained in:
parent
7d9044ab29
commit
60ada5f6a3
20 changed files with 582 additions and 335 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { getLogger } from '@stock-bot/logger';
|
||||
import { handlerRegistry, type HandlerConfig, type ScheduledJobConfig } from '@stock-bot/queue';
|
||||
import { handlerRegistry, createJobHandler, type HandlerConfig, type ScheduledJobConfig } from '@stock-bot/queue';
|
||||
import type { ServiceContainer } from '@stock-bot/di';
|
||||
import { symbolOperations } from './operations';
|
||||
|
||||
const logger = getLogger('symbols-handler');
|
||||
|
|
@ -34,8 +35,22 @@ const symbolsHandlerConfig: HandlerConfig = {
|
|||
},
|
||||
};
|
||||
|
||||
export function initializeSymbolsHandler(): void {
|
||||
export function initializeSymbolsHandler(container: ServiceContainer): void {
|
||||
logger.info('Registering symbols handler...');
|
||||
handlerRegistry.registerHandler(HANDLER_NAME, symbolsHandlerConfig);
|
||||
|
||||
// Update operations to use container
|
||||
const containerAwareOperations = Object.entries(symbolOperations).reduce((acc, [key, operation]) => {
|
||||
acc[key] = createJobHandler(async (payload: any) => {
|
||||
return operation(payload, container);
|
||||
});
|
||||
return acc;
|
||||
}, {} as Record<string, any>);
|
||||
|
||||
const symbolsHandlerConfigWithContainer: HandlerConfig = {
|
||||
...symbolsHandlerConfig,
|
||||
operations: containerAwareOperations,
|
||||
};
|
||||
|
||||
handlerRegistry.register(HANDLER_NAME, symbolsHandlerConfigWithContainer);
|
||||
logger.info('Symbols handler registered successfully');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue