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

Method Post

pocketflow.go:489–516  ·  view source on GitHub ↗

Post calls the user-defined PostFunc.

(ctx *PfContext, prepResult any, execResult any)

Source from the content-addressed store, hash-verified

487
488// Post calls the user-defined PostFunc.
489func (bn *BatchNode) Post(ctx *PfContext, prepResult any, execResult any) (string, error) {
490 // Type assertions needed as interface methods deal with 'any'
491 prepSlice, okPrep := prepResult.([]any)
492 if prepResult != nil && !okPrep { // Allow nil prepResult
493 return "", newPocketFlowError(fmt.Sprintf("Internal error: prepResult in BatchNode %T Post was not []any (%T)", bn, prepResult), nil)
494 }
495
496 execSlice, okExec := execResult.([]any)
497 if execResult != nil && !okExec { // Allow nil execResult (e.g., if prep was empty)
498 return "", newPocketFlowError(fmt.Sprintf("Internal error: execResult in BatchNode %T Post was not []any (%T)", bn, execResult), nil)
499 }
500 // Ensure slices are not nil if they were originally nil/empty, matching Java behaviour somewhat
501 if prepSlice == nil {
502 prepSlice = []any{}
503 }
504 if execSlice == nil {
505 execSlice = []any{}
506 }
507
508 if bn.PostFunc == nil {
509 return DefaultAction, nil
510 }
511 action, err := bn.PostFunc(ctx, bn.params, prepSlice, execSlice)
512 if err == nil && action == "" {
513 action = DefaultAction
514 }
515 return action, err
516}
517
518func (bn *BatchNode) Run(ctx *PfContext) (string, error) {
519 if len(bn.successors) > 0 {

Callers 1

InternalRunMethod · 0.95

Calls 1

newPocketFlowErrorFunction · 0.85

Tested by

no test coverage detected