moved handlers out of queue will be reused with event-bus

This commit is contained in:
Boki 2025-06-21 18:32:55 -04:00
parent 36cb84b343
commit dc4bd7b18e
16 changed files with 145 additions and 295 deletions

View file

@ -1,4 +1,3 @@
import type { ServiceContainer } from '@stock-bot/di';
import { getLogger } from '@stock-bot/logger';
import type { IHandler, ExecutionContext } from '../types/types';
@ -9,7 +8,7 @@ import type { IHandler, ExecutionContext } from '../types/types';
export abstract class BaseHandler implements IHandler {
protected readonly logger;
constructor(protected readonly container: ServiceContainer) {
constructor(protected readonly container: any) {
this.logger = getLogger(this.constructor.name);
}
@ -23,7 +22,7 @@ export abstract class BaseHandler implements IHandler {
* Queue helper methods
*/
protected async scheduleOperation(operation: string, payload: unknown, delay?: number): Promise<void> {
const queue = await this.container.resolveAsync('queue');
const queue = await this.container.resolveAsync('queue') as any;
await queue.add(operation, payload, { delay });
}
@ -31,7 +30,7 @@ export abstract class BaseHandler implements IHandler {
* Get a service from the container
*/
protected async getService<T>(serviceName: string): Promise<T> {
return await this.container.resolveAsync<T>(serviceName);
return await this.container.resolveAsync(serviceName);
}
/**