Initial proxy manager refactor
This commit is contained in:
parent
84cb14680b
commit
da916222c1
6 changed files with 58 additions and 37 deletions
|
|
@ -7,7 +7,7 @@ import {
|
|||
handlerRegistry,
|
||||
type HandlerConfigWithSchedule,
|
||||
} from '@stock-bot/queue';
|
||||
import { proxyManager } from '@stock-bot/utils';
|
||||
import { ProxyManager } from '@stock-bot/utils';
|
||||
|
||||
const logger = getLogger('webshare-provider');
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ export function initializeWebShareProvider() {
|
|||
|
||||
if (proxies.length > 0) {
|
||||
// Update the centralized proxy manager
|
||||
await proxyManager.updateProxies(proxies);
|
||||
await ProxyManager.getInstance().updateProxies(proxies);
|
||||
|
||||
logger.info('Updated proxy manager with WebShare proxies', {
|
||||
count: proxies.length,
|
||||
|
|
@ -66,7 +66,7 @@ export function initializeWebShareProvider() {
|
|||
const validationResults = await validateStoredProxies();
|
||||
|
||||
// Update proxy manager with validated proxies
|
||||
await proxyManager.updateProxies(validationResults.workingProxies);
|
||||
await ProxyManager.getInstance().updateProxies(validationResults.workingProxies);
|
||||
|
||||
logger.info('Proxy validation completed', {
|
||||
totalChecked: validationResults.totalChecked,
|
||||
|
|
@ -87,7 +87,7 @@ export function initializeWebShareProvider() {
|
|||
}),
|
||||
|
||||
'get-stats': createJobHandler(async () => {
|
||||
const stats = proxyManager.getStats();
|
||||
const stats = ProxyManager.getInstance().getStats();
|
||||
logger.info('Proxy manager statistics', stats);
|
||||
return stats;
|
||||
}),
|
||||
|
|
@ -128,7 +128,7 @@ export function initializeWebShareProvider() {
|
|||
|
||||
// Legacy function for backward compatibility - now uses centralized proxy manager
|
||||
export async function getProxy(): Promise<string | null> {
|
||||
const proxy = await proxyManager.getRandomProxy();
|
||||
const proxy = ProxyManager.getInstance().getRandomProxy();
|
||||
if (!proxy) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue