external_func.go 487 B

123456789101112131415161718192021222324
  1. package services
  2. import "github.com/emqx/kuiper/xstream/api"
  3. type ExternalFunc struct {
  4. methodName string
  5. exe executor
  6. }
  7. func (f *ExternalFunc) Validate(_ []interface{}) error {
  8. return nil
  9. }
  10. func (f *ExternalFunc) Exec(args []interface{}, ctx api.FunctionContext) (interface{}, bool) {
  11. if r, err := f.exe.InvokeFunction(ctx, f.methodName, args); err != nil {
  12. return err, false
  13. } else {
  14. return r, true
  15. }
  16. }
  17. func (f *ExternalFunc) IsAggregate() bool {
  18. return false
  19. }