Merged in feature/textextraction (pull request #110)

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
This commit is contained in:
Michael McGuinness
2025-04-02 18:50:03 +00:00
parent e6a4cb3990
commit 81e7223560
226 changed files with 17283 additions and 2744 deletions
+3 -19
View File
@@ -2,15 +2,12 @@ package queryversionsyncrunner
import (
"context"
"encoding/json"
"log/slog"
queryversionsync "queryorchestration/internal/query/versionsync"
"github.com/go-playground/validator/v10"
"github.com/google/uuid"
"github.com/aws/aws-sdk-go-v2/service/sqs/types"
)
const Name = "queryVersionSyncRunner"
@@ -32,24 +29,11 @@ func New(validator *validator.Validate, svc *Services) Runner {
}
type Body struct {
ID uuid.UUID `json:"id" validate:"required,uuid"`
QueryID uuid.UUID `json:"id" validate:"required,uuid"`
}
func (s *Runner) Process(ctx context.Context, req *types.Message) bool {
var body Body
err := json.Unmarshal([]byte(*req.Body), &body)
if err != nil {
slog.Error("parsing body", "messageId", *req.MessageId, "body", *req.Body)
return true
}
err = s.validator.Struct(body)
if err != nil {
slog.Error("invalid body", "messageId", *req.MessageId, "error", err)
return true
}
err = s.svc.Sync.Sync(ctx, body.ID)
func (s *Runner) Process(ctx context.Context, body Body) bool {
err := s.svc.Sync.Sync(ctx, body.QueryID)
if err != nil {
slog.Error("unable to process", "error", err)
return false
+9 -27
View File
@@ -2,7 +2,6 @@ package queryversionsyncrunner_test
import (
"context"
"encoding/json"
"fmt"
"testing"
@@ -14,7 +13,6 @@ import (
queuemock "queryorchestration/mocks/queue"
"github.com/aws/aws-sdk-go-v2/service/sqs"
"github.com/aws/aws-sdk-go-v2/service/sqs/types"
"github.com/go-playground/validator/v10"
"github.com/google/uuid"
"github.com/pashagolub/pgxmock/v3"
@@ -24,7 +22,7 @@ import (
)
type QuerySyncConfig struct {
runner.BaseConfig
runner.BaseConfig[queryversionsyncrunner.Body]
clientsync.ClientSyncConfig
}
@@ -50,23 +48,17 @@ func TestQueryRunner(t *testing.T) {
t.Run("valid", func(t *testing.T) {
doc := queryversionsyncrunner.Body{
ID: uuid.New(),
}
bodyBytes, err := json.Marshal(doc)
require.NoError(t, err)
body := string(bodyBytes)
msg := &types.Message{
Body: &body,
QueryID: uuid.New(),
}
clientOne := uuid.New()
clientTwo := uuid.New()
clientIds := []uuid.UUID{
clientOne := "hello"
clientTwo := "bye"
clientIds := []string{
clientOne,
clientTwo,
}
pool.ExpectQuery("name: ListQueryClientIDs :many").WithArgs(&doc.ID).
pool.ExpectQuery("name: ListQueryClientIDs :many").WithArgs(&doc.QueryID).
WillReturnRows(
pgxmock.NewRows([]string{"clientId"}).
AddRow(clientOne).
@@ -77,7 +69,7 @@ func TestQueryRunner(t *testing.T) {
SendMessage(
mock.Anything,
mock.MatchedBy(func(in *sqs.SendMessageInput) bool {
return *in.QueueUrl == cfg.ClientSyncURL && *in.MessageBody == fmt.Sprintf("{\"id\":\"%s\"}", clientIds[0].String())
return *in.QueueUrl == cfg.ClientSyncURL && *in.MessageBody == fmt.Sprintf("{\"id\":\"%s\"}", clientIds[0])
}),
mock.Anything,
).
@@ -86,22 +78,12 @@ func TestQueryRunner(t *testing.T) {
SendMessage(
mock.Anything,
mock.MatchedBy(func(in *sqs.SendMessageInput) bool {
return *in.QueueUrl == cfg.ClientSyncURL && *in.MessageBody == fmt.Sprintf("{\"id\":\"%s\"}", clientIds[1].String())
return *in.QueueUrl == cfg.ClientSyncURL && *in.MessageBody == fmt.Sprintf("{\"id\":\"%s\"}", clientIds[1])
}),
mock.Anything,
).
Return(&sqs.SendMessageOutput{}, nil)
assert.True(t, runner.Process(ctx, msg))
})
t.Run("invalid body", func(t *testing.T) {
body := "definitely invalid"
msgId := "id"
msg := &types.Message{
Body: &body,
MessageId: &msgId,
}
assert.True(t, runner.Process(ctx, msg))
assert.True(t, runner.Process(ctx, doc))
})
}