Files
query-orchestration/api/docInitRunner/runner.go
T
Michael McGuinness 81e7223560 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
2025-04-02 18:50:03 +00:00

54 lines
1.0 KiB
Go

package docinitrunner
import (
"context"
"log/slog"
"queryorchestration/internal/document"
documentinit "queryorchestration/internal/document/init"
"github.com/go-playground/validator/v10"
)
const Name = "docInitRunner"
type Services struct {
Document *documentinit.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 {
Bucket string `json:"bucket" validate:"required"`
Key string `json:"key" validate:"required"`
Hash string `json:"hash" validate:"required"`
ClientID string `json:"clientId" validate:"required"`
}
func (s Runner) Process(ctx context.Context, body Body) bool {
id, err := s.svc.Document.Create(ctx, &documentinit.Create{
ClientID: body.ClientID,
Location: document.Location{
Bucket: body.Bucket,
Key: body.Key,
},
Hash: body.Hash,
})
if err != nil {
return false
}
slog.Debug("created document", "id", id)
return true
}