Files
query-orchestration/api/docInitRunner/runner.go
T
Michael McGuinness fee71e7740 Merged in feature/postprocessing (pull request #114)
Feature/postprocessing

* tests

* passtest

* fixshorttests

* mosttests

* improvingbasedockerfile

* testspeeds

* testing

* host

* canparallel

* clean

* passfullsuite

* singlepagemax

* test

* findfeatures

* findstables

* tbls

* tablestoo

* tablestoo

* lateraltests

* tableloc

* cleanup

* inlinetable

* childids

* cleanup

* tests
2025-04-22 14:40:16 +00:00

52 lines
957 B
Go

package docinitrunner
import (
"context"
"log/slog"
documentinit "queryorchestration/internal/document/init"
"queryorchestration/internal/serviceconfig/objectstore"
)
const Name = "docInitRunner"
type Services struct {
Document *documentinit.Service
}
type Runner struct {
svc *Services
}
func New(svc *Services) Runner {
return Runner{
svc: svc,
}
}
type Body struct {
Bucket string `json:"bucket" validate:"required"`
Key string `json:"key" validate:"required"`
Hash string `json:"hash" validate:"required"`
}
func (s Runner) Process(ctx context.Context, body Body) bool {
key, err := objectstore.ParseBucketKey(body.Key)
if err != nil {
slog.Error("unable to parse key", "key", body.Key)
return false
}
id, err := s.svc.Document.Create(ctx, &documentinit.Create{
Key: key,
Bucket: body.Bucket,
Hash: body.Hash,
})
if err != nil {
return false
}
slog.Debug("created document", "id", id)
return true
}