creatorupdatordeprecate

This commit is contained in:
Michael McGuinness
2025-01-03 13:41:07 +00:00
parent 0ac156f0e1
commit 788b21594c
36 changed files with 545 additions and 226 deletions
+36
View File
@@ -0,0 +1,36 @@
package query
import (
"context"
"fmt"
contextfull "queryorchestration/internal/contextFull"
jsonextractor "queryorchestration/internal/jsonExtractor"
queryprocessor "queryorchestration/internal/queryProcessor"
"github.com/google/uuid"
)
func (s *Service) Create(ctx context.Context, entity *queryprocessor.Create) (uuid.UUID, error) {
validator, err := s.getCreator(entity.Type)
if err != nil {
return uuid.Nil, err
}
id, err := validator.Create(ctx, entity)
if err != nil {
return uuid.Nil, err
}
return id, nil
}
func (s *Service) getCreator(qType queryprocessor.Type) (queryprocessor.Creator, error) {
switch qType {
case queryprocessor.TypeJsonExtractor:
return jsonextractor.NewCreator(s.db), nil
case queryprocessor.TypeContextFull:
return contextfull.NewCreator(s.db), nil
default:
return nil, fmt.Errorf("attempting to process invalid query type")
}
}