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

Method Post

pocketflow.go:792–813  ·  view source on GitHub ↗

Post for BatchFlow runs its PostBatchFunc.

(ctx *PfContext, prepResult any, execResult any)

Source from the content-addressed store, hash-verified

790
791// Post for BatchFlow runs its PostBatchFunc.
792func (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.
816func (bf *BatchFlow) Run(ctx *PfContext) (string, error) {

Callers 1

InternalRunMethod · 0.95

Calls 1

newPocketFlowErrorFunction · 0.85

Tested by

no test coverage detected