61 lines
No EOL
1.6 KiB
TypeScript
61 lines
No EOL
1.6 KiB
TypeScript
/**
|
|
* OperationContext - Unified context for handler operations
|
|
*
|
|
* TEMPORARILY DISABLED to avoid circular dependencies during library build
|
|
* Will be re-enabled once all core libraries are built
|
|
*/
|
|
|
|
import { getLogger, type Logger } from '@stock-bot/logger';
|
|
import type { ServiceResolver } from './service-container';
|
|
|
|
export interface OperationContextOptions {
|
|
handlerName: string;
|
|
operationName: string;
|
|
parentLogger?: Logger;
|
|
container?: ServiceResolver;
|
|
}
|
|
|
|
export class OperationContext {
|
|
public readonly logger: Logger;
|
|
private readonly container?: ServiceResolver;
|
|
|
|
constructor(options: OperationContextOptions) {
|
|
this.container = options.container;
|
|
this.logger = options.parentLogger || getLogger(`${options.handlerName}:${options.operationName}`);
|
|
}
|
|
|
|
/**
|
|
* Creates a new OperationContext with automatic resource management
|
|
* TEMPORARILY SIMPLIFIED - full implementation will be restored after build fixes
|
|
*/
|
|
static create(
|
|
handlerName: string,
|
|
operationName: string,
|
|
options: { container?: ServiceResolver; parentLogger?: Logger } = {}
|
|
): OperationContext {
|
|
return new OperationContext({
|
|
handlerName,
|
|
operationName,
|
|
...options,
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Cleanup method - simplified for now
|
|
*/
|
|
async dispose(): Promise<void> {
|
|
// Cleanup will be implemented when dependencies are resolved
|
|
}
|
|
|
|
/**
|
|
* Create child context - simplified for now
|
|
*/
|
|
createChild(operationName: string): OperationContext {
|
|
return new OperationContext({
|
|
handlerName: 'child',
|
|
operationName,
|
|
parentLogger: this.logger,
|
|
container: this.container,
|
|
});
|
|
}
|
|
} |