MCPcopy Create free account
hub / github.com/temporalio/temporal / updateComponentInExecution

Method updateComponentInExecution

chasm/chasmtest/test_engine.go:596–618  ·  view source on GitHub ↗
(
	ctx context.Context,
	execution *execution,
	ref chasm.ComponentRef,
	updateFn func(chasm.MutableContext, chasm.Component) error,
)

Source from the content-addressed store, hash-verified

594}
595
596func (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)

Callers 2

UpdateComponentMethod · 0.95

Calls 5

NewContextFunction · 0.92
NewMutableContextFunction · 0.92
ComponentMethod · 0.65
CloseTransactionMethod · 0.65
RefMethod · 0.65

Tested by

no test coverage detected