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

[FEATURE] - Improve EmailSender Interface to Use Pointer for SendEmail #12

Closed
JRocabruna opened this issue Jun 4, 2024 · 1 comment · Fixed by #16 or #14
Closed

[FEATURE] - Improve EmailSender Interface to Use Pointer for SendEmail #12

JRocabruna opened this issue Jun 4, 2024 · 1 comment · Fixed by #16 or #14
Assignees
Labels
enhancement New feature or request performance Improvements related to the efficiency and speed of the code. refactoring Code refactoring to improve structure without changing functionality.

Comments

@JRocabruna
Copy link
Member

Is your feature request related to a problem? Please describe.
Currently, the SendEmail method in the EmailSender interface accepts an EmailMessage struct by value. This approach can be inefficient as it involves copying the entire EmailMessage struct, which can be costly in terms of performance, especially when handling large messages or attachments.

Describe the solution you'd like
The proposed solution is to modify the SendEmail method in the EmailSender interface to accept a pointer to EmailMessage instead of the struct by value. This change will enhance performance by avoiding unnecessary copying of the struct. The updated interface definition would be:

type EmailSender interface {
    // SendEmail sends an email with the given message.
    // Parameters:
    // - message: A pointer to an EmailMessage struct containing the details of the email to be sent.
    // Returns:
    // - error: An error if sending the email fails, otherwise nil.
    SendEmail(message *EmailMessage) error
}

Describe alternatives you've considered
An alternative approach would involve keeping the current method signature and optimizing other parts of the code. However, this would not address the fundamental inefficiency of copying the EmailMessage struct. Passing a pointer is a more straightforward and effective solution.

Additional context
This feature will improve the performance of the gomail package by reducing the overhead associated with copying large structs. It aligns with Go best practices for handling large data structures and ensures more efficient memory usage. The implementation will include updates to existing tests and documentation to reflect this change.

Copy link

github-actions bot commented Jul 5, 2024

This issue is stale because it has been open for 30 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request performance Improvements related to the efficiency and speed of the code. refactoring Code refactoring to improve structure without changing functionality.
Projects
None yet
2 participants