Skip to content
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

refactor(send): Add MustSend method #48

Closed
nikoksr opened this issue Feb 17, 2021 · 1 comment
Closed

refactor(send): Add MustSend method #48

nikoksr opened this issue Feb 17, 2021 · 1 comment
Assignees
Labels
type/feature New feature or request

Comments

@nikoksr
Copy link
Owner

nikoksr commented Feb 17, 2021

Is your feature request related to a problem? Please describe.

As discussed here the error handling in notify.Send might not fit everybodys needs. There might be occasions where you want Notify to immediately stop sending the message to the other receivers in case the preceding receiver was not reachable. Maybe its a very crucial message and you need to make sure that it was send to all receivers successfully. On the other hand there might be occasions where you don't care if Notify might not be able to reach some of the receivers and you just want it to continue after not reaching a receiver.

Describe the solution you'd like

In addition to the current notify.Send method we will add the notify.MustSend method. notify.Send will keep its current behavior which is to keep sending messages even after an error occured but.. it will need to collate all errors into one (something like #22). Instead of joining these errors I'm rather thinking about adding a custom error type which holds an array of unreachable receivers. notify.MustSend on the other will return the first error right after it occurs, basically skipping all remaining receivers.

Example for new error:

type ErrSendToReceivers struct {
    Receivers []string
    Err            error
}
@nikoksr nikoksr added the type/feature New feature or request label Feb 17, 2021
@nikoksr nikoksr self-assigned this Feb 17, 2021
@nikoksr
Copy link
Owner Author

nikoksr commented Feb 23, 2021

I started working on this issues and realized there was a problem with our idea.

For services like notify.Discord, our idea works well. You can either return a potential error immediately (MustSend behavior) or collect it in an error array (Send behavior) if a single receiver fails. But services like notify.AmazonSES manage the receiver list by itself, so we can't control the behavior whether the service should ignore single failed receivers or not. This would lead to some services supporting our intended behavior and some not.

The behavior should be predictable and not different from service to service. Closing this for now, discussion may keep going.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant