feat: enhance job and user models with additional fields

- Added VideoID, UserID, and TimeLimit fields to the job model.
- Removed unused referral fields from the user model.
- Updated job creation and update logic to handle new fields.
- Refactored job service to work with updated job model.
- Replaced cache interface with Redis adapter in service layer.
- Introduced a Dead Letter Queue (DLQ) for failed jobs in Redis.
- Updated gRPC server to accommodate changes in job handling.
- Removed obsolete cache package and related files.
This commit is contained in:
2026-03-26 00:33:45 +07:00
parent dfd999e058
commit bb7f7b0bb3
19 changed files with 270 additions and 329 deletions

View File

@@ -9,6 +9,7 @@ import (
"fmt"
"net/http"
"net/url"
"strconv"
"strings"
"time"
@@ -23,7 +24,6 @@ import (
appv1 "stream.api/internal/api/proto/app/v1"
"stream.api/internal/database/model"
"stream.api/internal/middleware"
"stream.api/internal/video/runtime/domain"
"stream.api/internal/video/runtime/services"
)
@@ -52,31 +52,32 @@ func adminPageLimitOffset(pageValue int32, limitValue int32) (int32, int32, int)
offset := int((page - 1) * limit)
return page, limit, offset
}
func buildAdminJob(job *domain.Job) *appv1.AdminJob {
func buildAdminJob(job *model.Job) *appv1.AdminJob {
if job == nil {
return nil
}
agentID := strconv.FormatInt(*job.AgentID, 10)
return &appv1.AdminJob{
Id: job.ID,
Status: string(job.Status),
Priority: int32(job.Priority),
UserId: job.UserID,
Name: job.Name,
TimeLimit: job.TimeLimit,
InputUrl: job.InputURL,
OutputUrl: job.OutputURL,
TotalDuration: job.TotalDuration,
CurrentTime: job.CurrentTime,
Progress: job.Progress,
AgentId: job.AgentID,
Logs: job.Logs,
Config: job.Config,
Cancelled: job.Cancelled,
RetryCount: int32(job.RetryCount),
MaxRetries: int32(job.MaxRetries),
CreatedAt: timestamppb.New(job.CreatedAt),
UpdatedAt: timestamppb.New(job.UpdatedAt),
VideoId: stringPointerOrNil(job.VideoID),
Status: string(*job.Status),
Priority: int32(*job.Priority),
UserId: *job.UserID,
Name: job.ID,
TimeLimit: *job.TimeLimit,
InputUrl: *job.InputURL,
OutputUrl: *job.OutputURL,
TotalDuration: *job.TotalDuration,
CurrentTime: *job.CurrentTime,
Progress: *job.Progress,
AgentId: &agentID,
Logs: *job.Logs,
Config: *job.Config,
Cancelled: *job.Cancelled,
RetryCount: int32(*job.RetryCount),
MaxRetries: int32(*job.MaxRetries),
CreatedAt: timestamppb.New(*job.CreatedAt),
UpdatedAt: timestamppb.New(*job.UpdatedAt),
VideoId: stringPointerOrNil(*job.VideoID),
}
}
func buildAdminAgent(agent *services.AgentWithStats) *appv1.AdminAgent {