Skip to content

Commit

Permalink
rename parameters, add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ychebotarev committed Nov 18, 2024
1 parent 25fb27a commit ed6e84a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions service/history/workflow/mutable_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ type (
MaxSearchAttributeValueSize int
}

UpdateActivityCallback func(*persistencespb.ActivityInfo, MutableState)
ActivityUpdater func(*persistencespb.ActivityInfo, MutableState)

MutableState interface {
callbacks.CanGetNexusCompletion
Expand Down Expand Up @@ -360,7 +360,7 @@ type (
baseRunLowestCommonAncestorEventID int64,
baseRunLowestCommonAncestorEventVersion int64,
)
UpdateActivity(string, UpdateActivityCallback) error
UpdateActivity(string, ActivityUpdater) error
UpdateActivityTimerHeartbeat(int64, time.Time)
UpdateActivityProgress(ai *persistencespb.ActivityInfo, request *workflowservice.RecordActivityTaskHeartbeatRequest)
UpdateUserTimer(*persistencespb.TimerInfo) error
Expand Down
12 changes: 11 additions & 1 deletion service/history/workflow/mutable_state_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -4940,6 +4940,16 @@ func (ms *MutableStateImpl) updateActivityInfoForRetries(
})
}

/*
UpdateActivity function updates the existing pending activity via the updater callback.
To update an activity, we need to do the following steps:
* preserve the original size of the activity
* preserve the original state of the activity
* call the updater callback to update the activity
* calculate new size of the activity
* respond to the changes of the activity state (like changes to pause)
*/

func (ms *MutableStateImpl) UpdateActivity(activityId string, updater ActivityUpdater) error {
ai, activityFound := ms.GetActivityByActivityID(activityId)
if !activityFound {
Expand All @@ -4953,7 +4963,7 @@ func (ms *MutableStateImpl) UpdateActivity(activityId string, updater ActivityUp
prevPause = prev.Paused
}

updateCallback(ai, ms)
updater(ai, ms)

if prevPause != ai.Paused {
err := ms.updatePauseInfoSearchAttribute()
Expand Down

0 comments on commit ed6e84a

Please sign in to comment.