feat: add remote worker system for distributed translation
- Add remote translator worker (Docker) that connects via WebSocket - Add backend Go handlers for remote worker CRUD (REST + WebSocket) - Add frontend Admin panel for managing remote workers - Add ProtectedRoute component to secure admin routes - Add PostgreSQL schema for remote_workers table - Fix duplicate Load function in config.go - Fix frontend duplicate fetchStatus function - Fix Dockerfiles missing go.sum (use go mod download + tidy) Features: - Workers connect to server via WebSocket (no ports needed) - API key authentication per worker - Job assigner automatically distributes translation jobs - Worker status tracking (online/offline/disabled) - Timeout handling for stuck jobs
This commit is contained in:
parent
b8e48f3199
commit
8093cc1e40
21 changed files with 2065 additions and 58 deletions
41
backend/internal/models/remote_worker.go
Normal file
41
backend/internal/models/remote_worker.go
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type RemoteWorker struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
APIKey string `json:"api_key,omitempty"`
|
||||
Capabilities string `json:"capabilities"`
|
||||
Status string `json:"status"`
|
||||
LastSeen *time.Time `json:"last_seen,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
type TranslationJob struct {
|
||||
ID int64 `json:"id"`
|
||||
NewsID int64 `json:"noticia_id"`
|
||||
LangFrom string `json:"lang_from"`
|
||||
LangTo string `json:"lang_to"`
|
||||
Title string `json:"title"`
|
||||
Summary string `json:"summary"`
|
||||
}
|
||||
|
||||
type TranslationResult struct {
|
||||
JobID int64 `json:"job_id"`
|
||||
TitleTr string `json:"title_trad"`
|
||||
SummaryTr string `json:"resumen_trad"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
type WSClientMessage struct {
|
||||
Type string `json:"type"`
|
||||
Capabilities string `json:"capabilities,omitempty"`
|
||||
WorkerName string `json:"worker_name,omitempty"`
|
||||
Result *TranslationResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type WSServerMessage struct {
|
||||
Type string `json:"type"`
|
||||
Job *TranslationJob `json:"job,omitempty"`
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue