-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathruntime_processor_creator.go
59 lines (50 loc) · 1.54 KB
/
runtime_processor_creator.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package pluto
import "fmt"
func init() {
// TODO: Runtime processor creators should be added by HTTP APIs.
PredefinedProcessors["RUNTIME_PROCESSOR_CREATOR_WRITE_TO_IO"] = func([]Value) (p Processor, err error) {
defer creatorPanicHandler("RUNTIME_PROCESSOR_CREATOR_WRITE_TO_IO", &err)()
return RuntimeProcessorCreator{
PredefinedProcessorName: ProcessorName_WriteToInputOutput,
AppendName: "processor",
}, err
}
}
// RuntimeProcessorCreator
// Deprecated
type RuntimeProcessorCreator struct {
PredefinedProcessorName string
AppendName string
}
func (p RuntimeProcessorCreator) Process(processable Processable) (Processable, bool) {
a, ok := processable.GetBody().(map[string]any)
if !ok {
ApplicationLogger.Debug(ApplicationLog{
Message: "Body is not map[string]any",
})
return processable, false
}
creator, found := PredefinedProcessors[p.PredefinedProcessorName]
if !found {
return processable, false
}
processor, err := creator(processable.GetBody().([]Value))
if err != nil {
ApplicationLogger.Error(ApplicationLog{
Message: fmt.Sprintf("Runtime processor creator failed to create the processor (%s)", p.PredefinedProcessorName),
Extra: map[string]any{"details": err},
})
return processable, false
}
a[p.AppendName] = processor
processable.SetBody(a)
return processable, true
}
func (p RuntimeProcessorCreator) GetDescriptor() ProcessorDescriptor {
return ProcessorDescriptor{
Name: "RUNTIME_PROCESSOR_CREATOR",
Description: "",
Input: "",
Output: "",
}
}