(snap *Snapshot, manager executorManager, modelRegistry modelRegistry, providerModels map[string][]*registry.ModelInfo, registrations []executorRegistration, nextProviders map[string]struct{}, modelClientRegistrations []modelClientRegistration, nextModelClients map[string]struct{})
| 856 | } |
| 857 | |
| 858 | func (h *Host) commitExecutorState(snap *Snapshot, manager executorManager, modelRegistry modelRegistry, providerModels map[string][]*registry.ModelInfo, registrations []executorRegistration, nextProviders map[string]struct{}, modelClientRegistrations []modelClientRegistration, nextModelClients map[string]struct{}) { |
| 859 | if h == nil || manager == nil { |
| 860 | return |
| 861 | } |
| 862 | |
| 863 | h.mu.Lock() |
| 864 | if h.Snapshot() != snap { |
| 865 | h.mu.Unlock() |
| 866 | return |
| 867 | } |
| 868 | |
| 869 | h.providerModels = make(map[string][]*registryModelInfo, len(providerModels)) |
| 870 | for provider, models := range providerModels { |
| 871 | h.providerModels[provider] = cloneRegistryModels(models) |
| 872 | } |
| 873 | |
| 874 | staleProviders := make([]string, 0) |
| 875 | for provider := range h.executorProviders { |
| 876 | if _, okProvider := nextProviders[provider]; !okProvider { |
| 877 | staleProviders = append(staleProviders, provider) |
| 878 | } |
| 879 | } |
| 880 | h.executorProviders = nextProviders |
| 881 | if nextModelClients == nil { |
| 882 | nextModelClients = make(map[string]struct{}) |
| 883 | } |
| 884 | staleModelClients := make([]string, 0) |
| 885 | for clientID := range h.executorModelClientIDs { |
| 886 | if _, okClient := nextModelClients[clientID]; !okClient { |
| 887 | staleModelClients = append(staleModelClients, clientID) |
| 888 | } |
| 889 | } |
| 890 | h.executorModelClientIDs = nextModelClients |
| 891 | |
| 892 | for _, registration := range registrations { |
| 893 | if registration.adapter == nil || registration.provider == "" { |
| 894 | continue |
| 895 | } |
| 896 | manager.RegisterExecutor(registration.adapter) |
| 897 | } |
| 898 | for _, provider := range staleProviders { |
| 899 | existing, okExecutor := manager.Executor(provider) |
| 900 | if !okExecutor || !h.ownsExecutor(existing) { |
| 901 | continue |
| 902 | } |
| 903 | manager.UnregisterExecutor(provider) |
| 904 | } |
| 905 | h.mu.Unlock() |
| 906 | |
| 907 | if modelRegistry == nil { |
| 908 | return |
| 909 | } |
| 910 | for _, registration := range modelClientRegistrations { |
| 911 | modelRegistry.RegisterClient(registration.clientID, registration.provider, registration.models) |
| 912 | } |
| 913 | for _, clientID := range staleModelClients { |
| 914 | modelRegistry.UnregisterClient(clientID) |
| 915 | } |
no test coverage detected