got symbols and exchanges working with sessions
This commit is contained in:
parent
f05d26d703
commit
174346ea2f
1 changed files with 14 additions and 7 deletions
|
|
@ -60,11 +60,18 @@ export async function createSessions(): Promise<void> {
|
|||
}
|
||||
logger.info('Creating QM sessions...');
|
||||
for (const [sessionId, sessionArray] of Object.entries(sessionCache)) {
|
||||
// remove any sessions with failedCalls > 10
|
||||
// const filteredArray = sessionArray.filter(session => session.failedCalls <= 10);
|
||||
// sessionCache[sessionId] = filteredArray;
|
||||
// if sessionArray is empty or has less than 5 sessions, create a new session
|
||||
while (sessionArray.length < 2) {
|
||||
const initialCount = sessionArray.length;
|
||||
const filteredArray = sessionArray.filter(session => session.failedCalls <= 10);
|
||||
sessionCache[sessionId] = filteredArray;
|
||||
|
||||
const removedCount = initialCount - filteredArray.length;
|
||||
if (removedCount > 0) {
|
||||
logger.info(
|
||||
`Removed ${removedCount} sessions with excessive failures for ${sessionId}. Remaining: ${filteredArray.length}`
|
||||
);
|
||||
}
|
||||
|
||||
while (sessionCache[sessionId].length < 5) {
|
||||
logger.info(`Creating new session for ${sessionId}`);
|
||||
const proxy = getProxy();
|
||||
if (proxy === null) {
|
||||
|
|
@ -103,10 +110,10 @@ export async function createSessions(): Promise<void> {
|
|||
logger.info('QM session created successfully', {
|
||||
sessionId,
|
||||
sessionData,
|
||||
sessionCount: sessionCache[sessionId].length + 1,
|
||||
});
|
||||
newSession.headers['Datatool-Token'] = sessionData.token;
|
||||
console.log(newSession.headers);
|
||||
sessionArray.push(newSession);
|
||||
sessionCache[sessionId].push(newSession);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue