work on qm

This commit is contained in:
Boki 2025-06-21 23:45:57 -04:00
parent ca1f658be6
commit 3fb9df425c
5 changed files with 93 additions and 113 deletions

View file

@ -1,7 +1,7 @@
import { getLogger } from '@stock-bot/logger';
import type { IHandler, ExecutionContext } from '../types/types';
import { createJobHandler, handlerRegistry, type HandlerConfigWithSchedule } from '@stock-bot/types';
import type { IServiceContainer } from '../types/service-container';
import { handlerRegistry, createJobHandler, type HandlerConfigWithSchedule } from '@stock-bot/types';
import type { ExecutionContext, IHandler } from '../types/types';
/**
* Abstract base class for all handlers with improved DI
@ -11,7 +11,7 @@ export abstract class BaseHandler implements IHandler {
protected readonly logger;
private handlerName: string;
constructor(protected readonly services: IServiceContainer, handlerName?: string) {
constructor(readonly services: IServiceContainer, handlerName?: string) {
this.logger = getLogger(this.constructor.name);
// Read handler name from decorator first, then fallback to parameter or class name
const constructor = this.constructor as any;
@ -65,10 +65,7 @@ export abstract class BaseHandler implements IHandler {
return await method.call(this, input, context);
}
/**
* Queue helper methods - now type-safe and direct
*/
protected async scheduleOperation(operation: string, payload: unknown, delay?: number): Promise<void> {
async scheduleOperation(operation: string, payload: unknown, delay?: number): Promise<void> {
const queue = this.services.queue.getQueue(this.handlerName);
const jobData = {
handler: this.handlerName,