removing deprecations
This commit is contained in:
parent
fa67d666dc
commit
f6038d385f
21 changed files with 91 additions and 158 deletions
|
|
@ -6,7 +6,7 @@ import type { MongoDBClient } from '@stock-bot/mongodb';
|
|||
import type { PostgreSQLClient } from '@stock-bot/postgres';
|
||||
import type { ProxyManager } from '@stock-bot/proxy';
|
||||
import type { QuestDBClient } from '@stock-bot/questdb';
|
||||
import type { SmartQueueManager } from '@stock-bot/queue';
|
||||
import type { QueueManager } from '@stock-bot/queue';
|
||||
import type { IServiceContainer } from '@stock-bot/types';
|
||||
import type { AppConfig } from '../config/schemas';
|
||||
import type { HandlerScanner } from '../scanner';
|
||||
|
|
@ -25,7 +25,7 @@ export interface ServiceDefinitions {
|
|||
globalCache: CacheProvider | null;
|
||||
proxyManager: ProxyManager | null;
|
||||
browser: Browser;
|
||||
queueManager: SmartQueueManager | null;
|
||||
queueManager: QueueManager | null;
|
||||
|
||||
// Database clients
|
||||
mongoClient: MongoDBClient | null;
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ export function registerApplicationServices(
|
|||
if (config.queue?.enabled && config.redis.enabled) {
|
||||
container.register({
|
||||
queueManager: asFunction(({ logger, handlerRegistry }) => {
|
||||
const { SmartQueueManager } = require('@stock-bot/queue');
|
||||
const { QueueManager } = require('@stock-bot/queue');
|
||||
const queueConfig = {
|
||||
serviceName: config.service?.serviceName || config.service?.name || 'unknown',
|
||||
redis: {
|
||||
|
|
@ -79,7 +79,7 @@ export function registerApplicationServices(
|
|||
delayWorkerStart: config.queue!.delayWorkerStart ?? true, // Changed to true so ServiceApplication can start workers
|
||||
autoDiscoverHandlers: true,
|
||||
};
|
||||
return new SmartQueueManager(queueConfig, handlerRegistry, logger);
|
||||
return new QueueManager(queueConfig, handlerRegistry, logger);
|
||||
}).singleton(),
|
||||
});
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* Discovers and registers handlers with the DI container
|
||||
*/
|
||||
|
||||
import { asClass, asFunction, type AwilixContainer } from 'awilix';
|
||||
import { asFunction, type AwilixContainer } from 'awilix';
|
||||
import { glob } from 'glob';
|
||||
import type {
|
||||
HandlerConfiguration,
|
||||
|
|
@ -82,7 +82,7 @@ export class HandlerScanner {
|
|||
* Check if an exported value is a handler
|
||||
*/
|
||||
private isHandler(exported: any): boolean {
|
||||
if (typeof exported !== 'function') return false;
|
||||
if (typeof exported !== 'function') {return false;}
|
||||
|
||||
// Check for handler metadata added by decorators
|
||||
const hasHandlerName = !!(exported as any).__handlerName;
|
||||
|
|
|
|||
|
|
@ -3,16 +3,16 @@
|
|||
* Encapsulates common patterns for Hono-based microservices
|
||||
*/
|
||||
|
||||
import type { AwilixContainer } from 'awilix';
|
||||
import { Hono } from 'hono';
|
||||
import { cors } from 'hono/cors';
|
||||
import type { BaseAppConfig, UnifiedAppConfig } from '@stock-bot/config';
|
||||
import { toUnifiedConfig } from '@stock-bot/config';
|
||||
import type { HandlerRegistry } from '@stock-bot/handler-registry';
|
||||
import { getLogger, setLoggerConfig, shutdownLoggers, type Logger } from '@stock-bot/logger';
|
||||
import { Shutdown } from '@stock-bot/shutdown';
|
||||
import type { IServiceContainer } from '@stock-bot/types';
|
||||
import type { HandlerRegistry } from '@stock-bot/handler-registry';
|
||||
import type { ServiceDefinitions } from './container/types';
|
||||
import type { AwilixContainer } from 'awilix';
|
||||
|
||||
/**
|
||||
* Configuration for ServiceApplication
|
||||
|
|
@ -279,8 +279,8 @@ export class ServiceApplication {
|
|||
if (this.serviceConfig.enableHandlers && handlerInitializer) {
|
||||
this.logger.debug('Initializing handlers...');
|
||||
// Pass the service container with the DI container attached
|
||||
const containerWithDI = Object.assign({}, this.serviceContainer, {
|
||||
_diContainer: this.container
|
||||
const containerWithDI = Object.assign({}, this.serviceContainer, {
|
||||
_diContainer: this.container,
|
||||
});
|
||||
await handlerInitializer(containerWithDI);
|
||||
this.logger.info('Handlers initialized');
|
||||
|
|
@ -339,8 +339,10 @@ export class ServiceApplication {
|
|||
this.logger.debug('Creating scheduled jobs from registered handlers...');
|
||||
const handlerRegistry = this.container.resolve<HandlerRegistry>('handlerRegistry');
|
||||
const allHandlers = handlerRegistry.getAllHandlersWithSchedule();
|
||||
|
||||
this.logger.info(`Found ${allHandlers.size} handlers with scheduled jobs: ${Array.from(allHandlers.keys()).join(', ')}`);
|
||||
|
||||
this.logger.info(
|
||||
`Found ${allHandlers.size} handlers with scheduled jobs: ${Array.from(allHandlers.keys()).join(', ')}`
|
||||
);
|
||||
|
||||
let totalScheduledJobs = 0;
|
||||
for (const [handlerName, config] of allHandlers) {
|
||||
|
|
@ -368,9 +370,9 @@ export class ServiceApplication {
|
|||
hasHandlerRegistry: !!handlerRegistry,
|
||||
registeredHandlers: handlerRegistry.getHandlerNames(),
|
||||
});
|
||||
|
||||
|
||||
const queue = queueManager.getQueue(handlerName, {
|
||||
handlerRegistry: handlerRegistry
|
||||
handlerRegistry: handlerRegistry,
|
||||
});
|
||||
|
||||
for (const scheduledJob of config.scheduledJobs) {
|
||||
|
|
@ -395,7 +397,7 @@ export class ServiceApplication {
|
|||
operation: scheduledJob.operation,
|
||||
hasOperation: !!handlerRegistry.getOperation(handlerName, scheduledJob.operation),
|
||||
});
|
||||
|
||||
|
||||
await queue.addScheduledJob(
|
||||
scheduledJob.operation,
|
||||
jobData,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue