Updating router to provide new advanced routing logic

This commit is contained in:
2025-09-27 11:07:43 +00:00
parent f9e2bca7a1
commit b77efe8e55
8 changed files with 494 additions and 415 deletions

View File

@@ -1,36 +1 @@
package manager
import (
"gitlab.michelsen.id/phillmichelsen/tessera/services/data_service/internal/domain"
)
func identifierSetDifferences(oldIDs, nextIDs []domain.Identifier) (toAdd, toDel []domain.Identifier) {
oldSet := make(map[domain.Identifier]struct{}, len(oldIDs))
for _, id := range oldIDs {
oldSet[id] = struct{}{}
}
newSet := make(map[domain.Identifier]struct{}, len(nextIDs))
for _, id := range nextIDs {
newSet[id] = struct{}{}
if _, ok := oldSet[id]; !ok {
toAdd = append(toAdd, id)
}
}
for _, id := range oldIDs {
if _, ok := newSet[id]; !ok {
toDel = append(toDel, id)
}
}
return
}
func identifierMapToSlice(m map[domain.Identifier]struct{}) []domain.Identifier {
ids := make([]domain.Identifier, 0, len(m))
for id := range m {
ids = append(ids, id)
}
return ids
}