moved proxy.service to proxy.tasks
This commit is contained in:
parent
ead13257b3
commit
bf2fa003b9
3 changed files with 7 additions and 17 deletions
|
|
@ -5,17 +5,17 @@ export const proxyProvider: ProviderConfig = {
|
|||
service: 'proxy',
|
||||
operations: {
|
||||
'fetch-and-check': async (payload: { sources?: string[] }) => {
|
||||
const { proxyService } = await import('../services/proxy.service');
|
||||
const { proxyService } = await import('./proxy.tasks');
|
||||
return await proxyService.fetchProxiesFromSources();
|
||||
},
|
||||
|
||||
'check-specific': async (payload: { proxies: any[] }) => {
|
||||
const { proxyService } = await import('../services/proxy.service');
|
||||
const { proxyService } = await import('./proxy.tasks');
|
||||
return await proxyService.checkProxies(payload.proxies);
|
||||
},
|
||||
|
||||
'get-working-proxy': async (payload: { protocol?: string; country?: string; timeout?: number }) => {
|
||||
const { proxyService } = await import('../services/proxy.service');
|
||||
const { proxyService } = await import('./proxy.tasks');
|
||||
return await proxyService.getWorkingProxy();
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -65,24 +65,14 @@ export class ProxyService {
|
|||
this.httpClient = new HttpClient({
|
||||
timeout: 10000,
|
||||
}, this.logger);
|
||||
|
||||
// Start scheduled tasks
|
||||
this.initializeScheduling();
|
||||
|
||||
|
||||
this.logger.info('ProxyService initialized');
|
||||
}
|
||||
private async initializeScheduling() {
|
||||
try {
|
||||
// Queue manager will handle scheduling
|
||||
this.logger.info('Proxy scheduling will be handled by queue manager');
|
||||
} catch (error) {
|
||||
this.logger.error('Failed to initialize scheduling', { error });
|
||||
}
|
||||
}
|
||||
|
||||
// Add queue integration methods
|
||||
async queueProxyFetch(): Promise<string> {
|
||||
const { queueManager } = await import('./queue.service');
|
||||
const { queueManager } = await import('../services/queue.service');
|
||||
const job = await queueManager.addJob({
|
||||
type: 'proxy-fetch',
|
||||
service: 'proxy',
|
||||
|
|
@ -98,7 +88,7 @@ export class ProxyService {
|
|||
}
|
||||
|
||||
async queueProxyCheck(proxies: ProxyInfo[]): Promise<string> {
|
||||
const { queueManager } = await import('./queue.service');
|
||||
const { queueManager } = await import('../services/queue.service');
|
||||
const job = await queueManager.addJob({
|
||||
type: 'proxy-check',
|
||||
service: 'proxy',
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { proxyService } from './services/proxy.service.js';
|
||||
import { proxyService } from './providers/proxy.tasks.js';
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
|
||||
// Initialize logger for the demo
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue