-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathresolve_config.go
81 lines (68 loc) · 2.2 KB
/
resolve_config.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package pluto
// Config
// Deprecated
type Config struct {
Pipelines []struct {
Name string `json:"name"`
Processors []struct {
Name string `json:"name"`
Success []string `json:"success,omitempty"`
Fail []string `json:"fail,omitempty"`
} `json:"processors"`
} `json:"pipelines"`
}
// ResolveConfig
// Deprecated
func ResolveConfig(config Config) (o map[string]Pipeline) {
for _, pipeline := range config.Pipelines {
p := Pipeline{
Name: pipeline.Name,
ProcessorBucket: ProcessorBucket{},
}
for _, processor := range pipeline.Processors {
processorCreator, found := PredefinedProcessors[processor.Name]
if !found {
ApplicationLogger.Warning(ApplicationLog{
Message: "Predefined processor not found to attach to pipeline",
Extra: map[string]any{"processor_name": processor.Name},
})
continue
}
var conditionalProcessor ConditionalProcessor
conditionalProcessor.main, _ = processorCreator(nil)
if processor.Success == nil || len(processor.Success) <= 0 {
conditionalProcessor.success = ProcessorBucket{make([]Processor, 0)}
for _, successProcessor := range processor.Success {
processorCreator, found := PredefinedProcessors[successProcessor]
if !found {
ApplicationLogger.Warning(ApplicationLog{
Message: "Predefined processor not found to attach to success path",
Extra: map[string]any{"processor_name": successProcessor},
})
continue
}
pr, _ := processorCreator(nil)
conditionalProcessor.success.Attach(pr)
}
}
if processor.Fail == nil || len(processor.Fail) <= 0 {
conditionalProcessor.fail = ProcessorBucket{make([]Processor, 0)}
for _, failProcessor := range processor.Fail {
processorCreator, found := PredefinedProcessors[failProcessor]
if !found {
ApplicationLogger.Warning(ApplicationLog{
Message: "Predefined processor not found to attach to fail path",
Extra: map[string]any{"processor_name": failProcessor},
})
continue
}
pr, _ := processorCreator(nil)
conditionalProcessor.fail.Attach(pr)
}
}
p.ProcessorBucket.Attach(&conditionalProcessor)
}
o[pipeline.Name] = p
}
return
}