45
// Only a single task for a given type can be tracked for a given machine. If a task of the same type is already
46
// tracked, it will be overridden.
47
>
func TrackStateMachineTimer(ms historyi.MutableState, deadline time.Time, taskInfo *persistencespb.StateMachineTaskInfo) {
state_machine_timers.go
48
>
execInfo := ms.GetExecutionInfo()
49
>
group := &persistencespb.StateMachineTimerGroup{
50
>
Deadline: timestamppb.New(deadline),
51
>
Infos: []*persistencespb.StateMachineTaskInfo{taskInfo},
52
>
}
53
>
idx, groupFound := slices.BinarySearchFunc(execInfo.StateMachineTimers, group, func(a, b *persistencespb.StateMachineTimerGroup) int {
54
return a.Deadline.AsTime().Compare(b.Deadline.AsTime())
55
})
57
groupIdx := slices.IndexFunc(execInfo.StateMachineTimers[idx].Infos, func(info *persistencespb.StateMachineTaskInfo) bool {
58
return info.GetType() == taskInfo.GetType() && slices.EqualFunc(info.GetRef().GetPath(), taskInfo.GetRef().GetPath(), func(a, b *persistencespb.StateMachineKey) bool {