mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2026-01-28 21:44:26 +00:00
Better registry handling
This commit is contained in:
@@ -29,7 +29,23 @@ func NewModelRegistry() *DefaultModelRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SetDefaultRegistry(registry *DefaultModelRegistry) {
|
func SetDefaultRegistry(registry *DefaultModelRegistry) {
|
||||||
|
registriesMutex.Lock()
|
||||||
|
foundAt := -1
|
||||||
|
for idx, r := range registries {
|
||||||
|
if r == defaultRegistry {
|
||||||
|
foundAt = idx
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
defaultRegistry = registry
|
defaultRegistry = registry
|
||||||
|
if foundAt >= 0 {
|
||||||
|
registries[foundAt] = registry
|
||||||
|
} else {
|
||||||
|
registries = append([]*DefaultModelRegistry{registry}, registries...)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer registriesMutex.Unlock()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddRegistry adds a registry to the global list of registries
|
// AddRegistry adds a registry to the global list of registries
|
||||||
|
|||||||
Reference in New Issue
Block a user