2025-02-07 14:15:06 +00:00
|
|
|
package doctextrunner
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2025-03-05 19:49:03 +00:00
|
|
|
"log/slog"
|
2025-03-05 12:05:46 +00:00
|
|
|
|
2025-02-07 14:15:06 +00:00
|
|
|
documenttext "queryorchestration/internal/document/text"
|
|
|
|
|
|
|
|
|
|
"github.com/go-playground/validator/v10"
|
|
|
|
|
"github.com/google/uuid"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const Name = "docTextRunner"
|
|
|
|
|
|
|
|
|
|
type Services struct {
|
|
|
|
|
Text *documenttext.Service
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Runner struct {
|
|
|
|
|
validator *validator.Validate
|
|
|
|
|
svc *Services
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func New(validator *validator.Validate, svc *Services) Runner {
|
|
|
|
|
return Runner{
|
|
|
|
|
validator: validator,
|
|
|
|
|
svc: svc,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-11 15:22:59 +00:00
|
|
|
type Body struct {
|
2025-04-02 18:50:03 +00:00
|
|
|
DocumentID uuid.UUID `json:"id" validate:"required,uuid"`
|
2025-02-07 14:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
2025-04-02 18:50:03 +00:00
|
|
|
func (s Runner) Process(ctx context.Context, body Body) bool {
|
|
|
|
|
err := s.svc.Text.Extract(ctx, body.DocumentID)
|
2025-02-07 14:15:06 +00:00
|
|
|
if err != nil {
|
2025-03-05 19:49:03 +00:00
|
|
|
slog.Error("unable to process", "error", err)
|
|
|
|
|
return false
|
2025-02-07 14:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
2025-03-05 19:49:03 +00:00
|
|
|
return true
|
2025-02-07 14:15:06 +00:00
|
|
|
}
|