2025-02-12 19:00:25 +00:00
|
|
|
package docsyncrunner
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2025-03-05 19:49:03 +00:00
|
|
|
"log/slog"
|
2025-03-05 12:05:46 +00:00
|
|
|
|
2025-02-12 19:00:25 +00:00
|
|
|
documentsync "queryorchestration/internal/document/sync"
|
|
|
|
|
|
|
|
|
|
"github.com/google/uuid"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const Name = "docSyncRunner"
|
|
|
|
|
|
|
|
|
|
type Services struct {
|
|
|
|
|
Document *documentsync.Service
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Runner struct {
|
2025-04-22 14:40:16 +00:00
|
|
|
svc *Services
|
2025-02-12 19:00:25 +00:00
|
|
|
}
|
|
|
|
|
|
2025-04-22 14:40:16 +00:00
|
|
|
func New(svc *Services) Runner {
|
2025-02-12 19:00:25 +00:00
|
|
|
return Runner{
|
2025-04-22 14:40:16 +00:00
|
|
|
svc: svc,
|
2025-02-12 19:00:25 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Body struct {
|
2025-04-02 18:50:03 +00:00
|
|
|
DocumentID uuid.UUID `json:"id" validate:"required,uuid"`
|
2025-02-12 19:00:25 +00:00
|
|
|
}
|
|
|
|
|
|
2025-04-02 18:50:03 +00:00
|
|
|
func (s Runner) Process(ctx context.Context, body Body) bool {
|
|
|
|
|
err := s.svc.Document.Sync(ctx, body.DocumentID)
|
2025-02-12 19:00:25 +00:00
|
|
|
if err != nil {
|
2025-03-05 19:49:03 +00:00
|
|
|
slog.Error("unable to process", "error", err)
|
|
|
|
|
return false
|
2025-02-12 19:00:25 +00:00
|
|
|
}
|
|
|
|
|
|
2025-03-05 19:49:03 +00:00
|
|
|
return true
|
2025-02-12 19:00:25 +00:00
|
|
|
}
|