90353d8161
Doc Clean Structure * outline * isdocclean * placeholder for clean log * versionplustesting * versionplustesting * testspassed
55 lines
937 B
Go
55 lines
937 B
Go
package doccleanrunner
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
documentclean "queryorchestration/internal/document/clean"
|
|
|
|
"github.com/go-playground/validator/v10"
|
|
"github.com/google/uuid"
|
|
|
|
"github.com/aws/aws-sdk-go-v2/service/sqs/types"
|
|
)
|
|
|
|
const Name = "docCleanRunner"
|
|
|
|
type Services struct {
|
|
Clean *documentclean.Service
|
|
}
|
|
|
|
type Runner struct {
|
|
validator *validator.Validate
|
|
svc *Services
|
|
}
|
|
|
|
func New(validator *validator.Validate, svc *Services) Runner {
|
|
return Runner{
|
|
validator: validator,
|
|
svc: svc,
|
|
}
|
|
}
|
|
|
|
type Create struct {
|
|
ID uuid.UUID `json:"id" validate:"required,uuid"`
|
|
}
|
|
|
|
func (s Runner) Process(ctx context.Context, req *types.Message) error {
|
|
var body Create
|
|
err := json.Unmarshal([]byte(*req.Body), &body)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = s.validator.Struct(body)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = s.svc.Clean.Create(ctx, body.ID)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|