Documentation
¶
Overview ¶
Package mail provides a mail service
Index ¶
- Variables
- func MailWorker(mailQueue chan Mail, mailErr chan error, worker int)
- func ProcessMail(mailData Mail) error
- type EmbeddedImage
- type InstrumentedMailService
- func (ims *InstrumentedMailService) GetMailQueueDepth() int64
- func (ims *InstrumentedMailService) GetSystemHealthCallbacks() (getMailQueueDepth func() int64, getWorkerCount func() int64)
- func (ims *InstrumentedMailService) GetSystemStatus() int64
- func (ims *InstrumentedMailService) GetWorkerCount() int64
- func (ims *InstrumentedMailService) InstrumentedMailWorker(mailQueue chan Mail, mailErr chan error, workerCount int)
- func (ims *InstrumentedMailService) ProcessMailWithMetrics(ctx context.Context, mailData Mail) error
- func (ims *InstrumentedMailService) StartInstrumentedMailWorkers(mailQueue chan Mail, mailErr chan error, workerCount int)
- type Mail
- type TemplateEngine
Constants ¶
This section is empty.
Variables ¶
var TemplatesFS embed.FS
Functions ¶
func MailWorker ¶ added in v0.0.8
Worker processes emails from the mail queue nolint:revive // Keeping original name for backward compatibility
func ProcessMail ¶ added in v0.0.8
ProcessMail handles the actual sending of an email
Types ¶
type EmbeddedImage ¶ added in v0.0.11
type EmbeddedImage struct {
ContentID string // ContentID to be referenced in HTML, e.g., <img src="cid:image1">
Path string // Path to the image file
Data []byte // Raw image data (optional, used if Path is empty)
}
EmbeddedImage represents an image to be embedded in an email
type InstrumentedMailService ¶ added in v0.4.0
type InstrumentedMailService struct {
// contains filtered or unexported fields
}
InstrumentedMailService wraps the mail functionality with metrics collection
func NewInstrumentedMailService ¶ added in v0.4.0
func NewInstrumentedMailService(systemMetrics *metrics.SystemHealthMetrics) *InstrumentedMailService
NewInstrumentedMailService creates a new instrumented mail service
func (*InstrumentedMailService) GetMailQueueDepth ¶ added in v0.4.0
func (ims *InstrumentedMailService) GetMailQueueDepth() int64
GetMailQueueDepth returns the current depth of the mail queue
func (*InstrumentedMailService) GetSystemHealthCallbacks ¶ added in v0.4.0
func (ims *InstrumentedMailService) GetSystemHealthCallbacks() ( getMailQueueDepth func() int64, getWorkerCount func() int64, )
GetSystemHealthCallbacks returns callback functions for system health metrics
func (*InstrumentedMailService) GetSystemStatus ¶ added in v0.4.0
func (ims *InstrumentedMailService) GetSystemStatus() int64
GetSystemStatus returns the overall mail system health status Returns 1 if healthy, 0 if unhealthy
func (*InstrumentedMailService) GetWorkerCount ¶ added in v0.4.0
func (ims *InstrumentedMailService) GetWorkerCount() int64
GetWorkerCount returns the current number of active mail workers
func (*InstrumentedMailService) InstrumentedMailWorker ¶ added in v0.4.0
func (ims *InstrumentedMailService) InstrumentedMailWorker(mailQueue chan Mail, mailErr chan error, workerCount int)
InstrumentedMailWorker is an instrumented version of MailWorker that tracks metrics
func (*InstrumentedMailService) ProcessMailWithMetrics ¶ added in v0.4.0
func (ims *InstrumentedMailService) ProcessMailWithMetrics(ctx context.Context, mailData Mail) error
ProcessMailWithMetrics wraps ProcessMail with metrics collection
func (*InstrumentedMailService) StartInstrumentedMailWorkers ¶ added in v0.4.0
func (ims *InstrumentedMailService) StartInstrumentedMailWorkers(mailQueue chan Mail, mailErr chan error, workerCount int)
StartInstrumentedMailWorkers starts the instrumented mail workers This is a drop-in replacement for the original MailWorker function
type Mail ¶ added in v0.0.8
type Mail struct {
FromName string
FromEmail string
To string
Subject string
Body string // Plain text body (used only if Template is empty)
HTMLBody string // HTML body (used only if Template is empty)
Template string // Template name to use
TemplateData interface{} // Data to pass to the template
Attachments []string // Paths to files to attach
Images []EmbeddedImage // Images to embed in the email
MetaData interface{} // Additional metadata
}
Mail is a struct that holds the data for a mail
func (*Mail) AttachFile ¶ added in v0.0.11
AttachFile adds a file to the email attachments
type TemplateEngine ¶ added in v0.0.11
type TemplateEngine struct {
// contains filtered or unexported fields
}
TemplateEngine handles email template rendering
var ( MailQueue chan Mail GlobalTemplateEngine *TemplateEngine )
func GetTemplateEngine ¶ added in v0.0.11
func GetTemplateEngine() *TemplateEngine
GetTemplateEngine returns the global template engine instance
func (*TemplateEngine) Init ¶ added in v0.0.11
func (te *TemplateEngine) Init() error
Init initializes the template engine by loading all templates