-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprocessor.go
45 lines (36 loc) · 986 Bytes
/
processor.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package pluto
import "fmt"
var PredefinedProcessors = make(map[string]func([]Value) (Processor, error))
func creatorPanicHandler(processorName string, err *error) func() {
return func() {
if v := recover(); v != nil {
*err = fmt.Errorf("make sure you enter the arguments of (%s) correctly: %s", processorName, v.(error))
}
}
}
type Processor interface {
// GetDescriptor
// Deprecated
GetDescriptor() ProcessorDescriptor
// Process
// The boolean indicates that the next processor can be executed or not.
Process(Processable) (Processable, bool)
}
// ProcessorDescriptor
// Deprecated
type ProcessorDescriptor struct {
Name string
Description string
Input string
Output string
}
type EmptyProcessor struct {
}
func (p EmptyProcessor) Process(processable Processable) (Processable, bool) {
return processable, true
}
func (p EmptyProcessor) GetDescriptor() ProcessorDescriptor {
return ProcessorDescriptor{
Name: "Empty Processor",
}
}