mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
refactor: Convert GenerationJobManager methods to async for improved performance
- Updated methods in GenerationJobManager and InMemoryJobStore to be asynchronous, enhancing the handling of job creation, retrieval, and management. - Adjusted the ResumableAgentController and related routes to await job operations, ensuring proper flow and error handling. - Increased timeout duration in ResumableAgentController's startGeneration function to 3500ms for better subscriber readiness management.
This commit is contained in:
parent
f6bdc0970a
commit
7842bcc6e0
5 changed files with 104 additions and 107 deletions
|
|
@ -56,6 +56,9 @@ export interface ResumeState {
|
|||
* Implementations can use in-memory Map, Redis, KV store, etc.
|
||||
*/
|
||||
export interface IJobStore {
|
||||
/** Initialize the store (e.g., connect to Redis, start cleanup intervals) */
|
||||
initialize(): Promise<void>;
|
||||
|
||||
/** Create a new job */
|
||||
createJob(
|
||||
streamId: string,
|
||||
|
|
@ -83,6 +86,15 @@ export interface IJobStore {
|
|||
|
||||
/** Cleanup expired jobs */
|
||||
cleanup(): Promise<number>;
|
||||
|
||||
/** Get total job count */
|
||||
getJobCount(): Promise<number>;
|
||||
|
||||
/** Get job count by status */
|
||||
getJobCountByStatus(status: JobStatus): Promise<number>;
|
||||
|
||||
/** Destroy the store and release resources */
|
||||
destroy(): Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -117,6 +129,12 @@ export interface IEventTransport {
|
|||
|
||||
/** Listen for all subscribers leaving */
|
||||
onAllSubscribersLeft(streamId: string, callback: () => void): void;
|
||||
|
||||
/** Cleanup transport resources for a specific stream */
|
||||
cleanup(streamId: string): void;
|
||||
|
||||
/** Destroy all transport resources */
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -139,4 +157,7 @@ export interface IContentStateManager {
|
|||
|
||||
/** Clear content state for a job */
|
||||
clearContentState(streamId: string): void;
|
||||
|
||||
/** Destroy all content state resources */
|
||||
destroy(): void;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue