Files
query-orchestration/api/queryRunner/queryrunner.go
T
Jay Brown 15adaebfcd Merged in feature/serviceconfig-integration (pull request #38)
DRAFT PR : WIP working through ideas for integration

* movearound

* attempttwo

* openapi

* further sanding

* fix

* start on tests

* runthroughsingleconfig

* somechanges

* reflectissue

* removeerrs

* mostlyremovepanic

* removeenv

* noncfgtests

* go

* repo

* fix service config test

* add PWD to all

* test fix

* fix lint

* todo for later

* passingunittests

* alltests

* testlogger

* testloggername

* clean
2025-01-31 13:43:55 +00:00

53 lines
895 B
Go

package controllers
import (
"context"
"encoding/json"
"queryorchestration/internal/query"
"github.com/go-playground/validator/v10"
"github.com/aws/aws-sdk-go-v2/service/sqs/types"
"github.com/google/uuid"
)
type Services struct {
Query *query.Service
}
type QueryRunner struct {
validator *validator.Validate
svc *Services
}
func NewQueryRunner(validator *validator.Validate, svc *Services) QueryRunner {
return QueryRunner{
validator: validator,
svc: svc,
}
}
type DocumentQueryEvent struct {
ID uuid.UUID `json:"id"`
}
func (s *QueryRunner) Process(ctx context.Context, req *types.Message) error {
var body query.Document
err := json.Unmarshal([]byte(*req.Body), &body)
if err != nil {
return err
}
err = s.validator.Struct(body)
if err != nil {
return err
}
err = s.svc.Query.Sync(ctx, &body)
if err != nil {
return err
}
return nil
}