495
// processing a replication task.
496
// TODO: Remove this implementation once transition history is fully implemented.
497
>
func (cancelationMachineDefinition) CompareState(state1, state2 any) (int, error) {
statemachine.go
498
>
c1, ok := state1.(Cancelation)
499
>
if !ok {
500
return 0, fmt.Errorf("%w: expected state1 to be a Cancelation instance, got %v", hsm.ErrIncompatibleType, state1)
501
}
503
>
if !ok {
504
return 0, fmt.Errorf("%w: expected state2 to be a Cancelation instance, got %v", hsm.ErrIncompatibleType, state2)
505
}
506
508
>
if err != nil {
509
return 0, fmt.Errorf("failed to get progress for state1: %w", err)
510
}
512
>
if err != nil {
513
return 0, fmt.Errorf("failed to get progress for state2: %w", err)
514
}
516
return stage1 - stage2, nil
517
}