Files
query-orchestration/internal/document/store/process.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

57 lines
1.2 KiB
Go

package documentstore
import (
"context"
"log/slog"
docinitrunner "queryorchestration/api/docInitRunner"
"queryorchestration/internal/serviceconfig/objectstore"
"queryorchestration/internal/serviceconfig/queue"
)
type Params struct {
Event EventS3
Key string
Bucket string
Hash string
}
type EventS3 string
const (
EventS3ObjectCreatedPut = "ObjectCreated:Put"
)
func (s *Service) Process(ctx context.Context, params Params) error {
if !s.isSupportedEvent(params.Event) {
slog.Warn("unsupported event", "name", params.Event)
return nil
}
key, err := objectstore.ParseBucketKey(params.Key)
if err != nil {
slog.Error("unable to parse key", "key", params.Key)
return nil
}
queueParams := &queue.SendParams{}
switch key.Location {
case objectstore.Import:
queueParams.QueueURL = s.cfg.GetDocInitURL()
queueParams.Body = docinitrunner.Body{
Bucket: params.Bucket,
Key: params.Key,
Hash: params.Hash,
}
default:
slog.Info("unsupported key", "key", params.Key)
return nil
}
return s.cfg.SendToQueue(ctx, queueParams)
}
func (s *Service) isSupportedEvent(name EventS3) bool {
return name == EventS3ObjectCreatedPut
}