-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace Intervener with ActiveIntervener and MuteIntervener #3562
Replace Intervener with ActiveIntervener and MuteIntervener #3562
Conversation
This commit replaces the Intervener in timeinterval package with an ActiveIntervener and a MuteIntervener for active time intervals and mute time intervals. It avoids having a double-negative in TimeActiveStage where Mute returns true if its not muted rather than if it is muted, and will also enable us to mark alerts as muted or not within ActiveIntervener and MuteIntervener. Signed-off-by: George Robinson <[email protected]>
fd45cea
to
e8159a8
Compare
Signed-off-by: George Robinson <[email protected]>
intervals map[string][]TimeInterval | ||
} | ||
|
||
func (i *ActiveIntervener) Mutes(names []string, now time.Time) (bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of this - this is pretty much the same logic as the other but with a flipped conditional. I'd rather keep it as is and continue to have the !muted
on the stage itself.
This seems like a lot of code to change/add for the sake of a flipping a conditional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's OK. We'll then need to put the marker back into TimeMuteStage
and TimeActiveStage
though as otherwise Intervener
doesn't know if it's activing or muting.
This seems like a lot of code to change/add for the sake of a flipping a conditional.
Don't forget we'll also be adding the marker, so it won't just be the conditional that changes, but how alerts are marked as muted too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should introduce it then? It's hard for me to see the benefit of this as is. 😭
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do think making time active intervals adhere to the contract of Mute
is a good win in of itself. Mute no longer returns false when it should be muted, and true when it shouldn't be muted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my suggestion here would be to keep everything under 1 single interface but add an additional method to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That still doesn't work I'm afraid, because Intervener
doesn't know if the intervals in names
are active time intervals or mute time intervals.
This commit replaces the Intervener in timeinterval package with an ActiveIntervener and a MuteIntervener for active time intervals and mute time intervals. It avoids having a double-negative in TimeActiveStage where Mute returns true if its not muted rather than if it is muted, and will also enable us to mark alerts as muted or not within ActiveIntervener and MuteIntervener.