2025-02-03 17:30:50 +00:00
|
|
|
package queryrunner
|
2024-12-18 18:54:48 +00:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2025-03-05 19:49:03 +00:00
|
|
|
"log/slog"
|
2025-03-05 12:05:46 +00:00
|
|
|
|
2025-02-11 15:22:59 +00:00
|
|
|
resultset "queryorchestration/internal/query/result/set"
|
2024-12-18 18:54:48 +00:00
|
|
|
|
2025-02-14 10:56:24 +00:00
|
|
|
"github.com/google/uuid"
|
2024-12-18 18:54:48 +00:00
|
|
|
)
|
|
|
|
|
|
2025-02-03 17:30:50 +00:00
|
|
|
const Name = "queryRunner"
|
|
|
|
|
|
2025-01-24 16:12:25 +00:00
|
|
|
type Services struct {
|
2025-02-11 15:22:59 +00:00
|
|
|
ResultSet *resultset.Service
|
2025-01-24 16:12:25 +00:00
|
|
|
}
|
|
|
|
|
|
2025-02-03 17:30:50 +00:00
|
|
|
type Runner struct {
|
2025-04-22 14:40:16 +00:00
|
|
|
svc *Services
|
2024-12-18 18:54:48 +00:00
|
|
|
}
|
|
|
|
|
|
2025-04-22 14:40:16 +00:00
|
|
|
func New(svc *Services) Runner {
|
2025-02-03 17:30:50 +00:00
|
|
|
return Runner{
|
2025-04-22 14:40:16 +00:00
|
|
|
svc: svc,
|
2024-12-18 18:54:48 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-14 10:56:24 +00:00
|
|
|
type Body struct {
|
|
|
|
|
DocumentID uuid.UUID `json:"document_id" validate:"required,uuid"`
|
|
|
|
|
QueryID uuid.UUID `json:"query_id" validate:"required,uuid"`
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-02 18:50:03 +00:00
|
|
|
func (s *Runner) Process(ctx context.Context, body Body) bool {
|
|
|
|
|
err := s.svc.ResultSet.Set(ctx, &resultset.Set{
|
2025-02-11 15:22:59 +00:00
|
|
|
DocumentID: body.DocumentID,
|
|
|
|
|
QueryID: body.QueryID,
|
|
|
|
|
})
|
2024-12-18 18:54:48 +00:00
|
|
|
if err != nil {
|
2025-03-05 19:49:03 +00:00
|
|
|
slog.Error("unable to process", "error", err)
|
|
|
|
|
return false
|
2024-12-18 18:54:48 +00:00
|
|
|
}
|
|
|
|
|
|
2025-03-05 19:49:03 +00:00
|
|
|
return true
|
2024-12-18 18:54:48 +00:00
|
|
|
}
|