( ctx context.Context, execution *execution, ref chasm.ComponentRef, updateFn func(chasm.MutableContext, chasm.Component) error, )
| 594 | } |
| 595 | |
| 596 | func (e *Engine) updateComponentInExecution( |
| 597 | ctx context.Context, |
| 598 | execution *execution, |
| 599 | ref chasm.ComponentRef, |
| 600 | updateFn func(chasm.MutableContext, chasm.Component) error, |
| 601 | ) ([]byte, error) { |
| 602 | chasmCtx := chasm.NewContext(ctx, execution.node) |
| 603 | component, err := execution.node.Component(chasmCtx, ref) |
| 604 | if err != nil { |
| 605 | return nil, err |
| 606 | } |
| 607 | |
| 608 | mutableCtx := chasm.NewMutableContext(ctx, execution.node) |
| 609 | if err := updateFn(mutableCtx, component); err != nil { |
| 610 | return nil, err |
| 611 | } |
| 612 | |
| 613 | if _, err = execution.node.CloseTransaction(); err != nil { |
| 614 | return nil, err |
| 615 | } |
| 616 | |
| 617 | return mutableCtx.Ref(component) |
| 618 | } |
| 619 | |
| 620 | // refForComponent looks up the ComponentRef for a component instance by scanning |
| 621 | // all executions. It works because Node.CloseTransaction (called after every mutation) |
no test coverage detected