Documentation
¶
Overview ¶
Package email provides email sending functionality using the Resend API. It includes a Client interface for sending emails and a Tracker interface for tracking email requests.
Index ¶
Constants ¶
const ( ResendAPIKeyEnv = "RESEND_API_KEY" ResendBaseURLEnv = "RESEND_BASE_URL" )
Environment variable names for Resend configuration
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client interface {
Send(functionID string, req SendRequest) (*SendResponse, error)
}
Client is an interface for sending emails
type ConfigError ¶
type ConfigError struct {
Field string
}
ConfigError is returned when a required configuration is missing
func (*ConfigError) Error ¶
func (e *ConfigError) Error() string
type DefaultClient ¶
type DefaultClient struct {
// contains filtered or unexported fields
}
DefaultClient is the default implementation of Client using Resend
func NewDefaultClient ¶
func NewDefaultClient(envStore env.Store) *DefaultClient
NewDefaultClient creates a new email client
func (*DefaultClient) Send ¶
func (c *DefaultClient) Send(functionID string, req SendRequest) (*SendResponse, error)
Send sends an email using Resend
type MemoryTracker ¶
type MemoryTracker struct {
// contains filtered or unexported fields
}
MemoryTracker is an in-memory implementation of Tracker
func NewMemoryTracker ¶
func NewMemoryTracker() *MemoryTracker
NewMemoryTracker creates a new in-memory tracker
func (*MemoryTracker) Requests ¶
func (m *MemoryTracker) Requests(executionID string) []store.EmailRequest
Requests returns all email requests for the specified executionID
func (*MemoryTracker) RequestsPaginated ¶
func (m *MemoryTracker) RequestsPaginated(executionID string, limit, offset int) ([]store.EmailRequest, int64)
RequestsPaginated returns paginated email requests for the specified executionID
func (*MemoryTracker) Track ¶
func (m *MemoryTracker) Track(executionID string, req TrackRequest)
Track records an email request
type SQLiteTracker ¶
type SQLiteTracker struct {
// contains filtered or unexported fields
}
SQLiteTracker is a SQLite-backed implementation of Tracker
func NewSQLiteTracker ¶
func NewSQLiteTracker(db *sql.DB) *SQLiteTracker
NewSQLiteTracker creates a new SQLite-backed tracker
func (*SQLiteTracker) Requests ¶
func (s *SQLiteTracker) Requests(executionID string) []store.EmailRequest
Requests returns all email requests for the specified executionID
func (*SQLiteTracker) RequestsPaginated ¶
func (s *SQLiteTracker) RequestsPaginated(executionID string, limit, offset int) ([]store.EmailRequest, int64)
RequestsPaginated returns paginated email requests for the specified executionID
func (*SQLiteTracker) Track ¶
func (s *SQLiteTracker) Track(executionID string, req TrackRequest)
Track records an email request
type SendRequest ¶
type SendRequest struct {
From string
To []string
Subject string
Text string
HTML string
ReplyTo string
Cc []string
Bcc []string
Headers map[string]string
Tags []Tag
ScheduledAt string
}
SendRequest represents a request to send an email
type SendResponse ¶
SendResponse represents the response from sending an email
type TrackRequest ¶
type TrackRequest struct {
From string
To []string
Subject string
HasText bool
HasHTML bool
RequestJSON string
ResponseJSON *string
Status store.EmailRequestStatus
ErrorMessage *string
EmailID *string
DurationMs int64
}
TrackRequest contains the data needed to track an email request
type Tracker ¶
type Tracker interface {
Track(executionID string, req TrackRequest)
Requests(executionID string) []store.EmailRequest
RequestsPaginated(executionID string, limit, offset int) ([]store.EmailRequest, int64)
}
Tracker is an interface for tracking email requests executionID is used to isolate requests for each function execution