MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / commitModelClients

Method commitModelClients

internal/pluginhost/adapters.go:717–744  ·  view source on GitHub ↗
(snap *Snapshot, modelRegistry modelRegistry, registrations []modelClientRegistration, nextClients map[string]struct{}, nextProviders map[string]string, nextModelRegistrations map[string]pluginModelRegistration)

Source from the content-addressed store, hash-verified

715}
716
717func (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
746type executorManager interface {
747 Executor(provider string) (coreauth.ProviderExecutor, bool)

Callers 1

RegisterModelsMethod · 0.95

Calls 3

SnapshotMethod · 0.95
RegisterClientMethod · 0.65
UnregisterClientMethod · 0.65

Tested by

no test coverage detected