removing deprecations
This commit is contained in:
parent
fa67d666dc
commit
f6038d385f
21 changed files with 91 additions and 158 deletions
|
|
@ -1,7 +1,6 @@
|
|||
// Core exports
|
||||
export { Queue } from './queue';
|
||||
export { QueueManager } from './queue-manager';
|
||||
export { SmartQueueManager } from './smart-queue-manager';
|
||||
export { ServiceCache, createServiceCache } from './service-cache';
|
||||
// Service utilities
|
||||
export {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ export class QueueManager {
|
|||
private shutdownPromise: Promise<void> | null = null;
|
||||
private config: QueueManagerConfig;
|
||||
private readonly logger: Logger;
|
||||
|
||||
|
||||
// Service discovery features
|
||||
private serviceName?: string;
|
||||
private queueRoutes = new Map<string, QueueRoute>();
|
||||
|
|
@ -59,7 +59,7 @@ export class QueueManager {
|
|||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
this.config = config;
|
||||
this.serviceName = config.serviceName;
|
||||
this.handlerRegistry = handlerRegistry;
|
||||
|
|
@ -80,7 +80,7 @@ export class QueueManager {
|
|||
if (config.serviceName && config.autoDiscoverHandlers !== false && handlerRegistry) {
|
||||
this.discoverQueueRoutes();
|
||||
}
|
||||
|
||||
|
||||
this.logger.info('QueueManager initialized', {
|
||||
redis: `${config.redis.host}:${config.redis.port}`,
|
||||
service: this.serviceName,
|
||||
|
|
@ -97,11 +97,11 @@ export class QueueManager {
|
|||
getQueue(queueName: string, options: QueueOptions = {}): Queue {
|
||||
let fullQueueName = queueName;
|
||||
let isOwnQueue = true;
|
||||
|
||||
|
||||
// Handle service namespacing if service name is configured
|
||||
if (this.serviceName) {
|
||||
const parsed = parseQueueName(queueName);
|
||||
|
||||
|
||||
if (parsed) {
|
||||
// Already in service:handler format
|
||||
fullQueueName = queueName;
|
||||
|
|
@ -111,7 +111,7 @@ export class QueueManager {
|
|||
fullQueueName = getFullQueueName(this.serviceName, queueName);
|
||||
isOwnQueue = true;
|
||||
}
|
||||
|
||||
|
||||
// For cross-service queues, create without workers (producer-only)
|
||||
if (!isOwnQueue) {
|
||||
options = {
|
||||
|
|
@ -122,10 +122,10 @@ export class QueueManager {
|
|||
// For own service queues, include handler registry
|
||||
options = {
|
||||
...options,
|
||||
handlerRegistry: this.handlerRegistry
|
||||
handlerRegistry: this.handlerRegistry,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
queueName = fullQueueName;
|
||||
}
|
||||
// Return existing queue if it exists
|
||||
|
|
@ -487,9 +487,11 @@ export class QueueManager {
|
|||
|
||||
let workersStarted = 0;
|
||||
const queues = this.queues;
|
||||
|
||||
this.logger.info(`Starting workers for ${queues.size} queues: ${Array.from(queues.keys()).join(', ')} (service: ${this.serviceName})`);
|
||||
|
||||
|
||||
this.logger.info(
|
||||
`Starting workers for ${queues.size} queues: ${Array.from(queues.keys()).join(', ')} (service: ${this.serviceName})`
|
||||
);
|
||||
|
||||
for (const [queueName, queue] of queues) {
|
||||
// If we have a service name, check if this queue belongs to us
|
||||
if (this.serviceName) {
|
||||
|
|
@ -504,7 +506,7 @@ export class QueueManager {
|
|||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const workerCount = this.config.defaultQueueOptions?.workers || 1;
|
||||
const concurrency = this.config.defaultQueueOptions?.concurrency || 1;
|
||||
|
||||
|
|
@ -548,7 +550,7 @@ export class QueueManager {
|
|||
getConfig(): Readonly<QueueManagerConfig> {
|
||||
return { ...this.config };
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send a job to any queue (local or remote)
|
||||
* This is the main method for cross-service communication
|
||||
|
|
@ -564,7 +566,7 @@ export class QueueManager {
|
|||
const queue = this.getQueue(targetQueue);
|
||||
return queue.add(operation, { handler: targetQueue, operation, payload }, options);
|
||||
}
|
||||
|
||||
|
||||
// Resolve the target queue
|
||||
const route = this.resolveQueueRoute(targetQueue);
|
||||
if (!route) {
|
||||
|
|
@ -582,7 +584,7 @@ export class QueueManager {
|
|||
|
||||
// Use a producer queue for cross-service sending
|
||||
const producerQueue = this.getProducerQueue(route.fullName);
|
||||
|
||||
|
||||
const jobData: JobData = {
|
||||
handler: route.handler,
|
||||
operation,
|
||||
|
|
@ -599,7 +601,7 @@ export class QueueManager {
|
|||
|
||||
return producerQueue.add(operation, jobData, options);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resolve a queue name to a route
|
||||
*/
|
||||
|
|
@ -640,7 +642,7 @@ export class QueueManager {
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a producer queue for sending to other services
|
||||
*/
|
||||
|
|
@ -654,7 +656,7 @@ export class QueueManager {
|
|||
}
|
||||
return this.producerQueues.get(queueName)!;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Discover all available queue routes from handler registry
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ export class Queue {
|
|||
this.logger = logger || console;
|
||||
this.handlerRegistry = config.handlerRegistry;
|
||||
this.serviceName = config.serviceName;
|
||||
|
||||
|
||||
this.logger.debug('Queue constructor called', {
|
||||
queueName,
|
||||
serviceName: this.serviceName,
|
||||
|
|
@ -180,7 +180,7 @@ export class Queue {
|
|||
]);
|
||||
|
||||
const isPaused = await this.bullQueue.isPaused();
|
||||
|
||||
|
||||
// Get actual active worker count from BullMQ
|
||||
const activeWorkerCount = await this.getActiveWorkerCount();
|
||||
|
||||
|
|
@ -317,7 +317,7 @@ export class Queue {
|
|||
// Add a name to identify the worker
|
||||
name: `${this.serviceName || 'unknown'}_worker_${i}`,
|
||||
});
|
||||
|
||||
|
||||
this.logger.info(`Starting worker ${i + 1}/${workerCount} for queue`, {
|
||||
queueName: this.queueName,
|
||||
workerName: worker.name,
|
||||
|
|
@ -380,14 +380,14 @@ export class Queue {
|
|||
if (!this.handlerRegistry) {
|
||||
throw new Error('Handler registry not configured for worker processing');
|
||||
}
|
||||
|
||||
|
||||
this.logger.debug('Looking up handler in registry', {
|
||||
handler,
|
||||
operation,
|
||||
queueName: this.queueName,
|
||||
registeredHandlers: this.handlerRegistry.getHandlerNames(),
|
||||
});
|
||||
|
||||
|
||||
const jobHandler = this.handlerRegistry.getOperation(handler, operation);
|
||||
|
||||
if (!jobHandler) {
|
||||
|
|
@ -424,7 +424,7 @@ export class Queue {
|
|||
this.logger.warn('Workers already started for queue', { queueName: this.queueName });
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
this.logger.info('Starting workers manually', {
|
||||
queueName: this.queueName,
|
||||
workerCount,
|
||||
|
|
@ -457,9 +457,9 @@ export class Queue {
|
|||
const workers = await this.bullQueue.getWorkers();
|
||||
return workers;
|
||||
} catch (error) {
|
||||
this.logger.error('Failed to get active workers', {
|
||||
queueName: this.queueName,
|
||||
error
|
||||
this.logger.error('Failed to get active workers', {
|
||||
queueName: this.queueName,
|
||||
error,
|
||||
});
|
||||
return [];
|
||||
}
|
||||
|
|
@ -473,9 +473,9 @@ export class Queue {
|
|||
const workers = await this.bullQueue.getWorkers();
|
||||
return workers.length;
|
||||
} catch (error) {
|
||||
this.logger.error('Failed to get active worker count', {
|
||||
queueName: this.queueName,
|
||||
error
|
||||
this.logger.error('Failed to get active worker count', {
|
||||
queueName: this.queueName,
|
||||
error,
|
||||
});
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -484,14 +484,16 @@ export class Queue {
|
|||
/**
|
||||
* Get detailed worker information
|
||||
*/
|
||||
async getWorkerDetails(): Promise<Array<{
|
||||
id: string;
|
||||
name?: string;
|
||||
addr?: string;
|
||||
age?: number;
|
||||
idle?: number;
|
||||
started?: number;
|
||||
}>> {
|
||||
async getWorkerDetails(): Promise<
|
||||
Array<{
|
||||
id: string;
|
||||
name?: string;
|
||||
addr?: string;
|
||||
age?: number;
|
||||
idle?: number;
|
||||
started?: number;
|
||||
}>
|
||||
> {
|
||||
try {
|
||||
const workers = await this.bullQueue.getWorkers();
|
||||
return workers.map(worker => ({
|
||||
|
|
@ -503,13 +505,11 @@ export class Queue {
|
|||
started: typeof worker.started === 'string' ? parseInt(worker.started) : worker.started,
|
||||
}));
|
||||
} catch (error) {
|
||||
this.logger.error('Failed to get worker details', {
|
||||
queueName: this.queueName,
|
||||
error
|
||||
this.logger.error('Failed to get worker details', {
|
||||
queueName: this.queueName,
|
||||
error,
|
||||
});
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
// SmartQueueManager has been merged into QueueManager
|
||||
// This file is kept for backward compatibility
|
||||
|
||||
import { QueueManager } from './queue-manager';
|
||||
import type { SmartQueueConfig } from './types';
|
||||
import type { HandlerRegistry } from '@stock-bot/handler-registry';
|
||||
import type { Logger } from '@stock-bot/logger';
|
||||
|
||||
/**
|
||||
* @deprecated Use QueueManager directly with serviceName config
|
||||
* SmartQueueManager functionality has been merged into QueueManager
|
||||
*/
|
||||
export class SmartQueueManager extends QueueManager {
|
||||
constructor(config: SmartQueueConfig, handlerRegistry?: HandlerRegistry, logger?: Logger) {
|
||||
// SmartQueueConfig already has serviceName, just pass it to QueueManager
|
||||
super(config, handlerRegistry, logger);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue