feat: pass uriMap to documentProvider

This commit is contained in:
Miroslav Cvetic 2025-03-04 16:51:11 +01:00
parent c3c0fe35a2
commit 9f858f42ea
2 changed files with 13 additions and 1 deletions

View File

@ -40,12 +40,23 @@ func (c ContentServer[indexDocument]) Provide(
if err != nil {
return nil, err
}
ids := make([]string, 0, len(documentInfos))
for _, documentInfo := range documentInfos {
ids = append(ids, string(documentInfo.DocumentID))
}
uriMap, err := c.contentserverClient.GetURIs(ctx, string(indexID), ids)
if err != nil {
return nil, err
}
documents := make([]*indexDocument, len(documentInfos))
for index, documentInfo := range documentInfos {
if documentProvider, ok := c.documentProviderFuncs[documentInfo.DocumentType]; !ok {
c.l.Warn("no document provider available for document type", zap.String("documentType", string(documentInfo.DocumentType)))
} else {
document, err := documentProvider(ctx, indexID, documentInfo.DocumentID)
document, err := documentProvider(ctx, indexID, documentInfo.DocumentID, uriMap)
if err != nil {
c.l.Error(
"index document not created",

View File

@ -19,6 +19,7 @@ type DocumentProviderFunc[indexDocument any] func(
ctx context.Context,
indexID IndexID,
documentID DocumentID,
uriMap map[string]string,
) (*indexDocument, error)
type DocumentInfo struct {