added disabled functioality

This commit is contained in:
Boki 2025-06-22 12:35:32 -04:00
parent fabf42dc7f
commit d8ae0cb3c5
16 changed files with 147 additions and 75 deletions

View file

@ -76,6 +76,22 @@ export function QueueSchedule(
};
}
/**
* Disabled decorator - marks a handler as disabled for auto-registration
* Handlers marked with @Disabled() will be skipped during auto-registration
*/
export function Disabled() {
return function <T extends { new (...args: any[]): {} }>(
target: T,
_context?: any
) {
// Store disabled flag on the constructor
(target as any).__disabled = true;
return target;
};
}
/**
* Combined decorator for scheduled operations
* Automatically creates both an operation and a schedule

View file

@ -22,7 +22,7 @@ export type { IServiceContainer } from './types/service-container';
export { createJobHandler } from './types/types';
// Decorators
export { Handler, Operation, QueueSchedule, ScheduledOperation } from './decorators/decorators';
export { Handler, Operation, QueueSchedule, ScheduledOperation, Disabled } from './decorators/decorators';
// Auto-registration utilities
export { autoRegisterHandlers, createAutoHandlerRegistry } from './registry/auto-register';

View file

@ -108,6 +108,12 @@ export async function autoRegisterHandlers(
for (const HandlerClass of handlerClasses) {
const handlerName = HandlerClass.name;
// Check if handler is disabled
if ((HandlerClass as any).__disabled) {
logger.info(`Skipping disabled handler: ${handlerName} from ${relativePath}`);
continue;
}
if (dryRun) {
logger.info(`[DRY RUN] Would register handler: ${handlerName} from ${relativePath}`);
registered.push(handlerName);

View file

@ -12,15 +12,15 @@ import type { ProxyManager } from '@stock-bot/proxy';
export interface IServiceContainer {
// Core infrastructure
readonly logger: any; // Logger instance
readonly cache: any; // Cache provider (Redis/Dragonfly)
readonly queue: any; // Queue manager (BullMQ)
readonly proxy: ProxyManager; // Proxy manager service
readonly cache?: any; // Cache provider (Redis/Dragonfly) - optional
readonly queue?: any; // Queue manager (BullMQ) - optional
readonly proxy?: ProxyManager; // Proxy manager service - optional (depends on cache)
readonly browser?: any; // Browser automation (Playwright)
// Database clients
readonly mongodb: any; // MongoDB client
readonly postgres: any; // PostgreSQL client
readonly questdb: any; // QuestDB client (time-series)
// Database clients - all optional to support selective enabling
readonly mongodb?: any; // MongoDB client
readonly postgres?: any; // PostgreSQL client
readonly questdb?: any; // QuestDB client (time-series)
// Optional extensions for future use
readonly custom?: Record<string, any>;