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 }