81e7223560
Text Extraction * bases * go * splitting * structure * movetoasync * movetoasync * settinguptrigger * reorder * storevent * standardisepollingvalidation * unittests * fixlint * fixlint * awscfg * generatesample * followthrough * tests * clena * store * externalidcleanup * clientid * local * baseunittests * putobjecttests * tests
48 lines
902 B
Go
48 lines
902 B
Go
package queryrunner
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
|
|
resultset "queryorchestration/internal/query/result/set"
|
|
|
|
"github.com/go-playground/validator/v10"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
const Name = "queryRunner"
|
|
|
|
type Services struct {
|
|
ResultSet *resultset.Service
|
|
}
|
|
|
|
type Runner struct {
|
|
validator *validator.Validate
|
|
svc *Services
|
|
}
|
|
|
|
func New(validator *validator.Validate, svc *Services) Runner {
|
|
return Runner{
|
|
validator: validator,
|
|
svc: svc,
|
|
}
|
|
}
|
|
|
|
type Body struct {
|
|
DocumentID uuid.UUID `json:"document_id" validate:"required,uuid"`
|
|
QueryID uuid.UUID `json:"query_id" validate:"required,uuid"`
|
|
}
|
|
|
|
func (s *Runner) Process(ctx context.Context, body Body) bool {
|
|
err := s.svc.ResultSet.Set(ctx, &resultset.Set{
|
|
DocumentID: body.DocumentID,
|
|
QueryID: body.QueryID,
|
|
})
|
|
if err != nil {
|
|
slog.Error("unable to process", "error", err)
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|