removed deprecated code
This commit is contained in:
parent
34c6c36695
commit
ca5f09c459
10 changed files with 18 additions and 377 deletions
|
|
@ -1,98 +0,0 @@
|
|||
/**
|
||||
* Service Registry Configuration
|
||||
* Maps services to their Redis databases and configurations
|
||||
*
|
||||
* @deprecated This static service registry has been replaced by runtime discovery
|
||||
* using the handler registry. Service ownership is now tracked when handlers are
|
||||
* registered, eliminating the need for static configuration.
|
||||
*
|
||||
* Migration:
|
||||
* - Service names are auto-discovered from handler registration
|
||||
* - Cache prefixes are generated using generateCachePrefix()
|
||||
* - Queue names use getFullQueueName() from service-utils
|
||||
* - Handler ownership is tracked by handlerRegistry.getHandlerService()
|
||||
*/
|
||||
|
||||
export interface ServiceConfig {
|
||||
/** Prefix for cache keys (e.g., 'cache:data-ingestion') */
|
||||
cachePrefix: string;
|
||||
/** List of handlers this service owns (auto-discovered if not provided) */
|
||||
handlers?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Central registry of all services and their configurations
|
||||
*
|
||||
* Database assignments:
|
||||
* - db:0 = All queues (unified queue database)
|
||||
* - db:1 = Global shared cache + service-specific caches
|
||||
*/
|
||||
export const SERVICE_REGISTRY: Record<string, ServiceConfig> = {
|
||||
'data-ingestion': {
|
||||
cachePrefix: 'cache:data-ingestion',
|
||||
handlers: ['ceo', 'qm', 'webshare', 'ib', 'proxy'],
|
||||
},
|
||||
'data-pipeline': {
|
||||
cachePrefix: 'cache:data-pipeline',
|
||||
handlers: ['exchanges', 'symbols'],
|
||||
},
|
||||
'web-api': {
|
||||
cachePrefix: 'cache:web-api',
|
||||
},
|
||||
// Add aliases for services with different naming conventions
|
||||
'webApi': {
|
||||
cachePrefix: 'cache:web-api',
|
||||
},
|
||||
'dataIngestion': {
|
||||
cachePrefix: 'cache:data-ingestion',
|
||||
handlers: ['ceo', 'qm', 'webshare', 'ib', 'proxy'],
|
||||
},
|
||||
'dataPipeline': {
|
||||
cachePrefix: 'cache:data-pipeline',
|
||||
handlers: ['exchanges', 'symbols'],
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Get service configuration
|
||||
*/
|
||||
export function getServiceConfig(serviceName: string): ServiceConfig | undefined {
|
||||
return SERVICE_REGISTRY[serviceName];
|
||||
}
|
||||
|
||||
/**
|
||||
* Find which service owns a handler
|
||||
*/
|
||||
export function findServiceForHandler(handlerName: string): string | undefined {
|
||||
for (const [serviceName, config] of Object.entries(SERVICE_REGISTRY)) {
|
||||
if (config.handlers?.includes(handlerName)) {
|
||||
return serviceName;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get full queue name with service namespace
|
||||
*/
|
||||
export function getFullQueueName(serviceName: string, handlerName: string): string {
|
||||
// Use {service_handler} format for Dragonfly optimization and BullMQ compatibility
|
||||
return `{${serviceName}_${handlerName}}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a full queue name into service and handler
|
||||
*/
|
||||
export function parseQueueName(fullQueueName: string): { service: string; handler: string } | null {
|
||||
// Match pattern {service_handler}
|
||||
const match = fullQueueName.match(/^\{([^_]+)_([^}]+)\}$/);
|
||||
|
||||
if (!match || !match[1] || !match[2]) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
service: match[1],
|
||||
handler: match[2],
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue