mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 13:32:08 +01:00
feat: add repository pattern, service layer architecture, and scheduler management
- Implement repository pattern for data access layer - Add comprehensive service layer for business logic - Create scheduler management system with health monitoring - Add bounded buffer utility for memory management - Enhance security audit logging with retention policies
This commit is contained in:
@ -128,7 +128,7 @@ class CircuitBreaker {
|
||||
class BatchProcessingError extends Error {
|
||||
constructor(
|
||||
message: string,
|
||||
public readonly _cause?: Error
|
||||
public readonly cause?: Error
|
||||
) {
|
||||
super(message);
|
||||
this.name = "BatchProcessingError";
|
||||
@ -145,7 +145,7 @@ class CircuitBreakerOpenError extends Error {
|
||||
class RetryableError extends Error {
|
||||
constructor(
|
||||
message: string,
|
||||
public readonly _isRetryable = true
|
||||
public readonly isRetryable = true
|
||||
) {
|
||||
super(message);
|
||||
this.name = "RetryableError";
|
||||
@ -411,7 +411,6 @@ export async function getPendingBatchRequests(
|
||||
},
|
||||
processingStatus: AIRequestStatus.PENDING_BATCHING,
|
||||
batchId: null,
|
||||
sessionId: { not: null },
|
||||
},
|
||||
include: {
|
||||
session: {
|
||||
@ -470,8 +469,6 @@ export async function createBatchRequest(
|
||||
);
|
||||
}
|
||||
|
||||
const _operationId = `batch-create-${crypto.randomUUID()}`;
|
||||
|
||||
try {
|
||||
await batchLogger.log(
|
||||
BatchLogLevel.INFO,
|
||||
@ -1250,8 +1247,26 @@ export async function retryFailedRequests(
|
||||
for (const request of failedRequests) {
|
||||
try {
|
||||
await retryWithBackoff(async () => {
|
||||
// Transform request to match processIndividualRequest interface
|
||||
const transformedRequest = {
|
||||
id: request.id,
|
||||
model: request.model,
|
||||
messages: [
|
||||
{
|
||||
role: "user",
|
||||
content: formatMessagesForProcessing(
|
||||
request.session?.messages || []
|
||||
),
|
||||
},
|
||||
],
|
||||
temperature: 0.1,
|
||||
max_tokens: 1000,
|
||||
processingType: request.processingType,
|
||||
session: request.session,
|
||||
};
|
||||
|
||||
// Process individual request using regular OpenAI API
|
||||
const result = await processIndividualRequest(request);
|
||||
const result = await processIndividualRequest(transformedRequest);
|
||||
await updateProcessingRequestWithResult(request.id, result);
|
||||
}, `Retry individual request ${request.id}`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user