|
@@ -19,7 +19,6 @@ package server
|
|
|
|
|
|
import (
|
|
import (
|
|
"fmt"
|
|
"fmt"
|
|
- "github.com/lf-edge/ekuiper/internal/pkg/model"
|
|
|
|
"github.com/lf-edge/ekuiper/internal/plugin"
|
|
"github.com/lf-edge/ekuiper/internal/plugin"
|
|
"strings"
|
|
"strings"
|
|
)
|
|
)
|
|
@@ -52,56 +51,17 @@ func (t *Server) doDesc(pt plugin.PluginType, name string) (interface{}, error)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-func (t *Server) RegisterPlugin(arg *model.PluginDesc, reply *string) error {
|
|
|
|
- p, err := getPluginByJson(arg, plugin.FUNCTION)
|
|
|
|
- if err != nil {
|
|
|
|
- return fmt.Errorf("Register plugin functions error: %s", err)
|
|
|
|
- }
|
|
|
|
- if len(p.GetSymbols()) == 0 {
|
|
|
|
- return fmt.Errorf("Register plugin functions error: Missing function list.")
|
|
|
|
- }
|
|
|
|
- err = nativeManager.RegisterFuncs(p.GetName(), p.GetSymbols())
|
|
|
|
- if err != nil {
|
|
|
|
- return fmt.Errorf("Create plugin error: %s", err)
|
|
|
|
- } else {
|
|
|
|
- *reply = fmt.Sprintf("Plugin %s is created.", p.GetName())
|
|
|
|
- }
|
|
|
|
- return nil
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-func (t *Server) ShowPlugins(arg int, reply *string) error {
|
|
|
|
- pt := plugin.PluginType(arg)
|
|
|
|
- l := nativeManager.List(pt)
|
|
|
|
- if len(l) == 0 {
|
|
|
|
- l = append(l, "No plugin is found.")
|
|
|
|
- }
|
|
|
|
- *reply = strings.Join(l, "\n")
|
|
|
|
- return nil
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-func (t *Server) ShowUdfs(_ int, reply *string) error {
|
|
|
|
- l := nativeManager.ListSymbols()
|
|
|
|
- if len(l) == 0 {
|
|
|
|
- l = append(l, "No udf is found.")
|
|
|
|
- }
|
|
|
|
- *reply = strings.Join(l, "\n")
|
|
|
|
- return nil
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-func (t *Server) DescUdf(arg string, reply *string) error {
|
|
|
|
- m, ok := nativeManager.GetPluginBySymbol(plugin.FUNCTION, arg)
|
|
|
|
- if !ok {
|
|
|
|
- return fmt.Errorf("Describe udf error: not found")
|
|
|
|
|
|
+func (t *Server) doShow(pt plugin.PluginType) (string, error) {
|
|
|
|
+ var result string
|
|
|
|
+ if pt == plugin.PORTABLE {
|
|
|
|
+ return "", fmt.Errorf("portable plugin support is disabled")
|
|
} else {
|
|
} else {
|
|
- j := map[string]string{
|
|
|
|
- "name": arg,
|
|
|
|
- "plugin": m,
|
|
|
|
- }
|
|
|
|
- r, err := marshalDesc(j)
|
|
|
|
- if err != nil {
|
|
|
|
- return fmt.Errorf("Describe udf error: %v", err)
|
|
|
|
|
|
+ l := nativeManager.List(pt)
|
|
|
|
+ if len(l) == 0 {
|
|
|
|
+ result = "No plugin is found."
|
|
|
|
+ } else {
|
|
|
|
+ result = strings.Join(l, "\n")
|
|
}
|
|
}
|
|
- *reply = r
|
|
|
|
|
|
+ return result, nil
|
|
}
|
|
}
|
|
- return nil
|
|
|
|
}
|
|
}
|