MCPcopy Create free account
hub / github.com/QuantumNous/new-api / rejectTaskPluginRoutingConflict

Function rejectTaskPluginRoutingConflict

controller/task_plugin.go:836–859  ·  view source on GitHub ↗

rejectTaskPluginRoutingConflict answers the request and returns true when the plugin about to serve key fails to compile or does not fit the live routing generation: row as the key's active version switched on, or the factory built-in when row is nil. A key without a built-in to fall back to has not

(c *gin.Context, key string, row *model.TaskPlugin)

Source from the content-addressed store, hash-verified

834// has nothing to check. Keeping every enabled plugin conflict-free leaves the
835// restart order nothing to decide.
836func rejectTaskPluginRoutingConflict(c *gin.Context, key string, row *model.TaskPlugin) bool {
837 var candidate *jsplugin.LoadedPlugin
838 var err error
839 if row != nil {
840 candidate, err = jsplugin.CompilePlugin(string(row.Source), jsplugin.Options{Key: row.Key, Version: row.Version})
841 } else if taskPluginHasFactory(key) {
842 var source string
843 if source, err = plugins.Source(key); err == nil {
844 candidate, err = jsplugin.CompilePlugin(source, jsplugin.Options{Key: key})
845 }
846 }
847 if err != nil {
848 taskPluginCompileError(c, err)
849 return true
850 }
851 if candidate == nil {
852 return false
853 }
854 if err = jsplugin.PreflightRoutingConflict(jsplugin.DefaultRegistry.Generation(), candidate); err != nil {
855 common.ApiErrorMsg(c, err.Error())
856 return true
857 }
858 return false
859}
860
861// taskPluginPricingIssues lists, after the registry sync, the task model prices
862// the plugin serving key cannot charge. The plugin change is already saved, so

Callers 3

UploadTaskPluginFunction · 0.85
DeleteTaskPluginVersionFunction · 0.85
SetTaskPluginStatusFunction · 0.85

Calls 8

CompilePluginFunction · 0.92
SourceFunction · 0.92
PreflightRoutingConflictFunction · 0.92
ApiErrorMsgFunction · 0.92
taskPluginHasFactoryFunction · 0.85
taskPluginCompileErrorFunction · 0.85
GenerationMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected