Skip to content
This repository has been archived by the owner on Aug 18, 2023. It is now read-only.

Update constants, vars, whatever to note that notification delays apply regardless of attempt count #57

Open
atc0005 opened this issue May 14, 2020 · 0 comments
Assignees
Labels
Milestone

Comments

@atc0005
Copy link
Owner

atc0005 commented May 14, 2020

While working on atc0005/brick#4, I was again reminded of how I ended up implementing notification delays:

// Delay between message submission attempts; this will *always*
// delay, regardless of whether the attempt is the first one or not

This comment above this portion of the select block:

// Delay between message submission attempts; this will *always*
// delay, regardless of whether the attempt is the first one or not
case <-notificationDelayTimer.C:
log.Debugf("sendMessage: Waited %v before notification attempt at %v",
notificationDelay,
time.Now().Format("15:04:05"),
)
ctxExpires, ctxExpired := ctx.Deadline()
if ctxExpired {
log.Debugf("sendMessage: WaitTimeout context expires at: %v", ctxExpires.Format("15:04:05"))
}
// check to see if context has expired during our delay
if ctx.Err() != nil {
msg := NotifyResult{
Val: fmt.Sprintf(
"sendMessage: context expired or cancelled at %v: %v, attempting to abort message submission",
time.Now().Format("15:04:05"),
ctx.Err().Error(),
),
Success: false,
}
log.Debug(msg.Val)
return msg
}

prompted me to quickly stub in this FIXME entry that I later removed for inclusion into this GH issue:

// FIXME: Need to update wording of constant, docs, etc to emphasize that
// the delay is enforced regardless of whether the notification attempt is
// the first, or a retry

Since I opted to apply the delay regardless of the delivery attempt, I should probably "unhook" the "retries" bit from the associated variables/constants associated with the delay. For example, it is in the function parameter list:

// define function/wrapper for sending details to Microsoft Teams
func sendMessage(
ctx context.Context,
webhookURL string,
msgCard goteamsnotify.MessageCard,
schedule time.Time,
retries int,
retriesDelay int,
) NotifyResult {

and is also used in the exported SendMessage() function from the atc0005/send2teams project:

// Submit message card, retry submission if needed up to specified number
// of retry attempts.
if err := send2teams.SendMessage(ctx, webhookURL, msgCard, retries, retriesDelay); err != nil {

As of this writing I've not reviewed that project yet to see if it has similar artifacts from the early design/implementation work, but it's likely.

@atc0005 atc0005 added this to the Future milestone May 14, 2020
@atc0005 atc0005 self-assigned this May 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant