some final fixes on session manager
This commit is contained in:
parent
966f6ac612
commit
8f1613697c
2 changed files with 24 additions and 5 deletions
|
|
@ -132,7 +132,7 @@ export class QMSessionManager {
|
|||
createdAt: session.createdAt instanceof Date ? session.createdAt.toISOString() : session.createdAt,
|
||||
id: session.uuid,
|
||||
sessionType,
|
||||
} as any;
|
||||
};
|
||||
|
||||
await this.cacheProvider.set(sessionKey, cachedSession, 86400); // 24 hour TTL
|
||||
|
||||
|
|
@ -261,8 +261,20 @@ export class QMSessionManager {
|
|||
/**
|
||||
* Get statistics about sessions
|
||||
*/
|
||||
async getStats(): Promise<Record<string, any>> {
|
||||
const stats: Record<string, any> = {};
|
||||
async getStats(): Promise<Record<string, {
|
||||
total: number;
|
||||
valid: number;
|
||||
failed: number;
|
||||
successfulCalls: number;
|
||||
failedCalls: number;
|
||||
}>> {
|
||||
const stats: Record<string, {
|
||||
total: number;
|
||||
valid: number;
|
||||
failed: number;
|
||||
successfulCalls: number;
|
||||
failedCalls: number;
|
||||
}> = {};
|
||||
|
||||
for (const [sessionType, sessionId] of Object.entries(QM_SESSION_IDS)) {
|
||||
const sessions = await this.getSessions(sessionId);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
|
||||
export interface QMSession {
|
||||
uuid?: string; // Unique identifier for the session
|
||||
uuid: string; // Unique identifier for the session
|
||||
proxy: string;
|
||||
headers: HeadersInit;
|
||||
successfulCalls: number;
|
||||
|
|
@ -46,7 +46,14 @@ export interface QMAuthResponse {
|
|||
error?: string;
|
||||
}
|
||||
|
||||
export interface CachedSession extends QMSession {
|
||||
export interface CachedSession {
|
||||
uuid: string;
|
||||
proxy: string;
|
||||
headers: HeadersInit;
|
||||
successfulCalls: number;
|
||||
failedCalls: number;
|
||||
lastUsed: string; // ISO string for Redis storage
|
||||
createdAt: string; // ISO string for Redis storage
|
||||
id: string;
|
||||
sessionType: string;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue