I'm practicing with command pattern and faced a problem. If I get an exception after executing a command, I need to repeat it 2 times (by adding it to the command queue), and then write logs if it fails again. I can't think of how should I count it
The code:
cmd := queue.Take()
err := cmd.Execute()
if err != nil {
// what i want to happen is the following
if this cmd throws error 2 times, then {
// Add the command to the command queue again
} else if it threw error more than 2 times, then {
// write logs
}
}
I have no idea how to make it working this way. Also I'm trying to follow SOLID rules, no kludges. Please, share your thoughts, I will be glad to read them. Thanks in advance