Files
query-orchestration/internal/document/create.go
T
Jay Brown 15adaebfcd Merged in feature/serviceconfig-integration (pull request #38)
DRAFT PR : WIP working through ideas for integration

* movearound

* attempttwo

* openapi

* further sanding

* fix

* start on tests

* runthroughsingleconfig

* somechanges

* reflectissue

* removeerrs

* mostlyremovepanic

* removeenv

* noncfgtests

* go

* repo

* fix service config test

* add PWD to all

* test fix

* fix lint

* todo for later

* passingunittests

* alltests

* testlogger

* testloggername

* clean
2025-01-31 13:43:55 +00:00

42 lines
761 B
Go

package document
import (
"context"
"queryorchestration/internal/database"
"queryorchestration/internal/database/repository"
"github.com/google/uuid"
)
type Location = string
type Create struct {
JobID uuid.UUID
Location Location
}
func (s *Service) Create(ctx context.Context, doc *Create) (uuid.UUID, error) {
hash, err := s.getHash()
if err != nil {
return uuid.Nil, err
}
dbid, err := s.cfg.GetDBQueries().CreateDocument(ctx, &repository.CreateDocumentParams{
Jobid: database.MustToDBUUID(doc.JobID),
Hash: hash,
Location: doc.Location,
})
if err != nil {
return uuid.Nil, err
}
id := database.MustToUUID(dbid)
return id, nil
}
func (s *Service) getHash() (string, error) {
// TODO
return "example_hash", nil
}