(snap *Snapshot, modelRegistry modelRegistry, registrations []modelClientRegistration, nextClients map[string]struct{}, nextProviders map[string]string, nextModelRegistrations map[string]pluginModelRegistration)
| 715 | } |
| 716 | |
| 717 | func (h *Host) commitModelClients(snap *Snapshot, modelRegistry modelRegistry, registrations []modelClientRegistration, nextClients map[string]struct{}, nextProviders map[string]string, nextModelRegistrations map[string]pluginModelRegistration) { |
| 718 | if h == nil || modelRegistry == nil { |
| 719 | return |
| 720 | } |
| 721 | |
| 722 | staleClients := make([]string, 0) |
| 723 | h.mu.Lock() |
| 724 | if h.Snapshot() != snap { |
| 725 | h.mu.Unlock() |
| 726 | return |
| 727 | } |
| 728 | for clientID := range h.modelClientIDs { |
| 729 | if _, okClient := nextClients[clientID]; !okClient { |
| 730 | staleClients = append(staleClients, clientID) |
| 731 | } |
| 732 | } |
| 733 | h.modelClientIDs = nextClients |
| 734 | h.modelProviders = nextProviders |
| 735 | h.modelRegistrations = nextModelRegistrations |
| 736 | h.mu.Unlock() |
| 737 | |
| 738 | for _, registration := range registrations { |
| 739 | modelRegistry.RegisterClient(registration.clientID, registration.provider, registration.models) |
| 740 | } |
| 741 | for _, clientID := range staleClients { |
| 742 | modelRegistry.UnregisterClient(clientID) |
| 743 | } |
| 744 | } |
| 745 | |
| 746 | type executorManager interface { |
| 747 | Executor(provider string) (coreauth.ProviderExecutor, bool) |
no test coverage detected