refactor: pre-M0 cleanup, core library hardening, and isolated dev/QA Docker stack
- Remove ~44k LOC of dead code, legacy v1 TS simulator/strategy stack, event-bus, analytics FastAPI prototype, legacy calculation archives, and unused deps (data-ingestion provider API handlers untouched) - Extract @stock-bot/di/http-security and isolate @stock-bot/browser to data-ingestion via ServiceContainerBuilder.withRegistrations() - Harden @stock-bot/mongodb read-only proxies, flatten @stock-bot/postgres with unified master+research migrations, and fix @stock-bot/config EnvLoader, ServiceApplication worker lifecycle, NamespacedCache.clear(), and BatchProcessor error propagation - Flatten workspace root (remove apps/stock/package.json) and collapse orchestrator re-export shims - Pin all Docker image versions, add shm_size/nofile/RAM caps and docker-compose.quant.yml, fix 05-add-visible-column.sql view recreation, and decouple dev/QA Compose project names for side-by-side execution - Update PLATFORM-PLAN, DATA-CONTRACTS (bars_1m PARTITION BY MONTH, Rust bulk ETL, DuckDB limits), MILESTONES, and servers docs
This commit is contained in:
parent
ce9e2df67c
commit
4cd6038063
432 changed files with 1247 additions and 44469 deletions
|
|
@ -1,135 +0,0 @@
|
|||
import type { ProxyInfo } from './types';
|
||||
|
||||
export interface ProxyConfig {
|
||||
protocol: string;
|
||||
host: string;
|
||||
port: number;
|
||||
auth?: {
|
||||
username: string;
|
||||
password: string;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple proxy manager for testing
|
||||
*/
|
||||
export class SimpleProxyManager {
|
||||
private proxies: Array<ProxyInfo & { id: string; active: boolean }> = [];
|
||||
private currentIndex = 0;
|
||||
private activeProxyIndex = 0;
|
||||
|
||||
addProxy(proxy: ProxyInfo & { id: string; active: boolean }): void {
|
||||
this.proxies.push(proxy);
|
||||
}
|
||||
|
||||
removeProxy(id: string): void {
|
||||
this.proxies = this.proxies.filter(p => p.id !== id);
|
||||
}
|
||||
|
||||
updateProxyStatus(id: string, active: boolean): void {
|
||||
const proxy = this.proxies.find(p => p.id === id);
|
||||
if (proxy) {
|
||||
proxy.active = active;
|
||||
}
|
||||
}
|
||||
|
||||
getProxies(): Array<ProxyInfo & { id: string; active: boolean }> {
|
||||
return [...this.proxies];
|
||||
}
|
||||
|
||||
getActiveProxies(): Array<ProxyInfo & { id: string; active: boolean }> {
|
||||
return this.proxies.filter(p => p.active);
|
||||
}
|
||||
|
||||
getNextProxy(): (ProxyInfo & { id: string; active: boolean }) | null {
|
||||
const activeProxies = this.getActiveProxies();
|
||||
if (activeProxies.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const proxy = activeProxies[this.activeProxyIndex % activeProxies.length];
|
||||
this.activeProxyIndex++;
|
||||
return proxy || null;
|
||||
}
|
||||
|
||||
getProxyConfig(proxy: ProxyInfo & { id: string; active: boolean }): ProxyConfig {
|
||||
const config: ProxyConfig = {
|
||||
protocol: proxy.protocol,
|
||||
host: proxy.host,
|
||||
port: proxy.port,
|
||||
};
|
||||
|
||||
if (proxy.username && proxy.password) {
|
||||
config.auth = {
|
||||
username: proxy.username,
|
||||
password: proxy.password,
|
||||
};
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
formatProxyUrl(proxy: ProxyInfo): string {
|
||||
let url = `${proxy.protocol}://`;
|
||||
if (proxy.username && proxy.password) {
|
||||
url += `${proxy.username}:${proxy.password}@`;
|
||||
}
|
||||
url += `${proxy.host}:${proxy.port}`;
|
||||
return url;
|
||||
}
|
||||
|
||||
async validateProxy(id: string): Promise<boolean> {
|
||||
const proxy = this.proxies.find(p => p.id === id);
|
||||
if (!proxy) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
const proxyUrl = this.formatProxyUrl(proxy);
|
||||
const response = await fetch('https://httpbin.org/ip', {
|
||||
// @ts-ignore - proxy option might not be in types
|
||||
proxy: proxyUrl,
|
||||
signal: AbortSignal.timeout(5000),
|
||||
});
|
||||
return response.ok;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async validateAllProxies(): Promise<Record<string, boolean>> {
|
||||
const results: Record<string, boolean> = {};
|
||||
|
||||
for (const proxy of this.proxies) {
|
||||
const isValid = await this.validateProxy(proxy.id);
|
||||
results[proxy.id] = isValid;
|
||||
|
||||
// Disable invalid proxies
|
||||
if (!isValid) {
|
||||
this.updateProxyStatus(proxy.id, false);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
getStatistics() {
|
||||
const stats = {
|
||||
total: this.proxies.length,
|
||||
active: this.proxies.filter(p => p.active).length,
|
||||
inactive: this.proxies.filter(p => !p.active).length,
|
||||
byProtocol: {} as Record<string, number>,
|
||||
};
|
||||
|
||||
this.proxies.forEach(proxy => {
|
||||
stats.byProtocol[proxy.protocol] = (stats.byProtocol[proxy.protocol] || 0) + 1;
|
||||
});
|
||||
|
||||
return stats;
|
||||
}
|
||||
|
||||
clear(): void {
|
||||
this.proxies = [];
|
||||
this.currentIndex = 0;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue