Post for BatchFlow runs its PostBatchFunc.
(ctx *PfContext, prepResult any, execResult any)
| 790 | |
| 791 | // Post for BatchFlow runs its PostBatchFunc. |
| 792 | func (bf *BatchFlow) Post(ctx *PfContext, prepResult any, execResult any) (string, error) { |
| 793 | // prepResult is the result of BatchFlow.Prep ([]*pfContext) |
| 794 | // execResult is the result of BatchFlow.Exec (which we defined as the same []*pfContext) |
| 795 | |
| 796 | batchPrepResult, okPrep := prepResult.([]map[string]any) |
| 797 | if prepResult != nil && !okPrep { |
| 798 | return "", newPocketFlowError(fmt.Sprintf("Internal error: prepResult in BatchFlow %T Post was not []*pfContext (%T)", bf, prepResult), nil) |
| 799 | } |
| 800 | if batchPrepResult == nil { |
| 801 | batchPrepResult = []map[string]any{} |
| 802 | } |
| 803 | |
| 804 | if bf.PostBatchFunc == nil { |
| 805 | return DefaultAction, nil |
| 806 | } |
| 807 | |
| 808 | action, err := bf.PostBatchFunc(ctx, bf.params, batchPrepResult) |
| 809 | if err == nil && action == "" { |
| 810 | action = DefaultAction |
| 811 | } |
| 812 | return action, err |
| 813 | } |
| 814 | |
| 815 | // Run starts the BatchFlow execution. |
| 816 | func (bf *BatchFlow) Run(ctx *PfContext) (string, error) { |
no test coverage detected