|
5 | 5 | "fmt" |
6 | 6 | "time" |
7 | 7 |
|
8 | | - "github.com/labstack/gommon/log" |
9 | 8 | "github.com/lithammer/shortuuid" |
10 | 9 | "github.com/serverledge-faas/serverledge/internal/function" |
11 | 10 | "github.com/serverledge-faas/serverledge/internal/node" |
@@ -40,11 +39,6 @@ func (workflow *Workflow) executeSimple(progress *Progress, input *PartialData, |
40 | 39 | return nil, progress, false, err |
41 | 40 | } |
42 | 41 |
|
43 | | - errSend := task.PrepareOutput(workflow, output) |
44 | | - if errSend != nil { |
45 | | - return nil, progress, false, fmt.Errorf("the node %s cannot send the output2: %v", task.String(), errSend) |
46 | | - } |
47 | | - |
48 | 42 | nextTask := task.GetNext()[0] |
49 | 43 | outputData := NewPartialData(ReqId(r.Id), nextTask, task.Id, output) |
50 | 44 |
|
@@ -151,65 +145,6 @@ func (s *SimpleNode) CheckInput(input map[string]interface{}) error { |
151 | 145 | return funct.Signature.CheckOrMatchInputs(input) |
152 | 146 | } |
153 | 147 |
|
154 | | -// PrepareOutput is used to send the output to the following function and if needed can be used to modify the SimpleNode output representation, like OutputPath |
155 | | -// TODO: this logic might be integrated in input checking |
156 | | -func (s *SimpleNode) PrepareOutput(workflow *Workflow, output map[string]interface{}) error { |
157 | | - funct, exists := function.GetFunction(s.Func) // we are getting the function from cache if not already downloaded |
158 | | - if !exists { |
159 | | - return fmt.Errorf("funtion %s doesn't exists", s.Func) |
160 | | - } |
161 | | - if funct.Signature == nil { |
162 | | - funct.Signature = function.SignatureInference(output) |
163 | | - log.Warnf("signature of function %s is nil. Output map: %v\n", funct.Name, output) |
164 | | - } |
165 | | - err := funct.Signature.CheckAllOutputs(output) |
166 | | - if err != nil { |
167 | | - return fmt.Errorf("error while checking outputs: %v", err) |
168 | | - } |
169 | | - // get signature of next nodes, if present and maps the output there |
170 | | - |
171 | | - // we have only one output node |
172 | | - task, _ := workflow.Find(s.GetNext()[0]) |
173 | | - |
174 | | - switch nodeType := task.(type) { |
175 | | - case *SimpleNode: |
176 | | - return nodeType.MapOutput(output) // needed to convert type of data from one node to the next so that its signature type-checks |
177 | | - } |
178 | | - |
179 | | - return nil |
180 | | -} |
181 | | - |
182 | | -// MapOutput transforms the output for the next simpleNode, to make it compatible with its Signature |
183 | | -func (s *SimpleNode) MapOutput(output map[string]interface{}) error { |
184 | | - funct, exists := function.GetFunction(s.Func) |
185 | | - if !exists { |
186 | | - return fmt.Errorf("function %s doesn't exist", s.Func) |
187 | | - } |
188 | | - sign := funct.Signature |
189 | | - |
190 | | - for _, def := range sign.GetInputs() { |
191 | | - _, present := output[def.Name] |
192 | | - if present { |
193 | | - continue |
194 | | - } else if len(sign.GetInputs()) > 1 { |
195 | | - return fmt.Errorf("key %s does not exist in output data: %v", def.Name, output) |
196 | | - } |
197 | | - |
198 | | - // find an entry in the output map that successfully checks the type of the InputDefinition |
199 | | - key, ok := def.FindEntryThatTypeChecks(output) |
200 | | - if ok { |
201 | | - val := output[key] |
202 | | - delete(output, key) |
203 | | - output[def.Name] = val |
204 | | - } else { |
205 | | - // otherwise if no one of the entry typechecks we are doomed |
206 | | - return fmt.Errorf("no output entry input-checks with the next function") |
207 | | - } |
208 | | - } |
209 | | - |
210 | | - return nil |
211 | | -} |
212 | | - |
213 | 148 | func (s *SimpleNode) GetNext() []TaskId { |
214 | 149 | // we only have one output |
215 | 150 | return []TaskId{s.OutputTo} |
|
0 commit comments