rpc_plugin_both.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2022 EMQ Technologies Co., Ltd.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //go:build !core || (rpc && portable && plugin)
  15. // +build !core rpc,portable,plugin
  16. package server
  17. import (
  18. "fmt"
  19. "github.com/lf-edge/ekuiper/internal/plugin"
  20. )
  21. func (t *Server) doRegister(pt plugin.PluginType, p plugin.Plugin) error {
  22. if pt == plugin.PORTABLE {
  23. return portableManager.Register(p)
  24. } else {
  25. return nativeManager.Register(pt, p)
  26. }
  27. }
  28. func (t *Server) doDelete(pt plugin.PluginType, name string, stopRun bool) error {
  29. if pt == plugin.PORTABLE {
  30. return portableManager.Delete(name)
  31. } else {
  32. return nativeManager.Delete(pt, name, stopRun)
  33. }
  34. }
  35. func (t *Server) doDesc(pt plugin.PluginType, name string) (interface{}, error) {
  36. var (
  37. result interface{}
  38. ok bool
  39. )
  40. if pt == plugin.PORTABLE {
  41. result, ok = portableManager.GetPluginInfo(name)
  42. } else {
  43. result, ok = nativeManager.GetPluginInfo(pt, name)
  44. }
  45. if !ok {
  46. return nil, fmt.Errorf("not found")
  47. }
  48. return result, nil
  49. }