MCPcopy Create free account
hub / github.com/The-Pocket/PocketFlow-Go / Exec

Method Exec

pocketflow.go:763–789  ·  view source on GitHub ↗

Exec for BatchFlow runs the orchestration for each batch item. The 'prepResult' here is the []*pfContext from BatchFlow.Prep.

(prepResult any)

Source from the content-addressed store, hash-verified

761// Exec for BatchFlow runs the orchestration for each batch item.
762// The 'prepResult' here is the []*pfContext from BatchFlow.Prep.
763func (bf *BatchFlow) Exec(prepResult any) (any, error) {
764 // We need the original context for the orchestrate calls.
765 // InternalRun should pass it. For now, let's assume prepResult contains it implicitly
766 // or redesign how context is passed through BatchFlow's Exec.
767 // Safest: Assume InternalRun passes the context correctly and prepResult is the list.
768 // Let's adjust the call site in InternalRun.
769
770 batchParamsList, ok := prepResult.([]*PfContext)
771 if prepResult != nil && !ok {
772 return "", newPocketFlowError(fmt.Sprintf("Internal error: prepResult in BatchFlow %T Exec was not []*pfContext (%T)", bf, prepResult), nil)
773 }
774 if batchParamsList == nil {
775 batchParamsList = []*PfContext{}
776 }
777
778 // We need the actual *pfContext. Where does it come from?
779 // It should be passed *alongside* the prepResult by InternalRun.
780 // Let's redefine Exec slightly to accept it, or rely on a field.
781 // Simpler: Let InternalRun handle context passing to orchestrate directly.
782 // Exec just needs to return the batchParamsList for Post.
783
784 // The actual orchestration happens in InternalRun using this list.
785 // This function's role is primarily semantic within the BaseNode interface call chain.
786 // It returns the data needed for Post.
787
788 return batchParamsList, nil
789}
790
791// Post for BatchFlow runs its PostBatchFunc.
792func (bf *BatchFlow) Post(ctx *PfContext, prepResult any, execResult any) (string, error) {

Callers

nothing calls this directly

Calls 1

newPocketFlowErrorFunction · 0.85

Tested by

no test coverage detected