48 lines
No EOL
1.4 KiB
TypeScript
48 lines
No EOL
1.4 KiB
TypeScript
/**
|
|
* Proxy Queue Operations - Queueing proxy operations
|
|
*/
|
|
import { OperationContext } from '@stock-bot/di';
|
|
import type { ProxyInfo } from '@stock-bot/proxy';
|
|
import type { IServiceContainer } from '@stock-bot/handlers';
|
|
|
|
export async function queueProxyFetch(container: IServiceContainer): Promise<string> {
|
|
const ctx = OperationContext.create('proxy', 'queue-fetch');
|
|
|
|
const queueManager = container.queue;
|
|
if (!queueManager) {
|
|
throw new Error('Queue manager not available');
|
|
}
|
|
|
|
const queue = queueManager.getQueue('proxy');
|
|
const job = await queue.add('proxy-fetch', {
|
|
handler: 'proxy',
|
|
operation: 'fetch-and-check',
|
|
payload: {},
|
|
priority: 5,
|
|
});
|
|
|
|
const jobId = job.id || 'unknown';
|
|
ctx.logger.info('Proxy fetch job queued', { jobId });
|
|
return jobId;
|
|
}
|
|
|
|
export async function queueProxyCheck(proxies: ProxyInfo[], container: IServiceContainer): Promise<string> {
|
|
const ctx = OperationContext.create('proxy', 'queue-check');
|
|
|
|
const queueManager = container.queue;
|
|
if (!queueManager) {
|
|
throw new Error('Queue manager not available');
|
|
}
|
|
|
|
const queue = queueManager.getQueue('proxy');
|
|
const job = await queue.add('proxy-check', {
|
|
handler: 'proxy',
|
|
operation: 'check-specific',
|
|
payload: { proxies },
|
|
priority: 3,
|
|
});
|
|
|
|
const jobId = job.id || 'unknown';
|
|
ctx.logger.info('Proxy check job queued', { jobId, count: proxies.length });
|
|
return jobId;
|
|
} |