service

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2026 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ComplaintRateThreshold = 0.1  // 0.1% complaint rate triggers circuit breaker
	BounceRateThreshold    = 10.0 // 10% bounce rate triggers circuit breaker
	BlockDetectionWindow   = 3    // 3 consecutive blocks from major providers
)

Circuit breaker thresholds

View Source
const (
	NewDomainAgeThreshold = 30 * 24 * time.Hour // 30 days
	NewIPFirstSeenWindow  = 7 * 24 * time.Hour  // 7 days
	MinimumSendingHistory = 100                 // minimum messages before warm-up ends
)

Thresholds for detecting new domains/IPs that need warm-up

Variables

View Source
var (
	// ErrCircuitBreakerActive indicates the domain is currently paused
	ErrCircuitBreakerActive = errors.New("circuit breaker active: sending paused for this domain")
	// ErrWarmUpLimitExceeded indicates the warm-up volume cap has been reached
	ErrWarmUpLimitExceeded = errors.New("warm-up limit exceeded: daily volume cap reached")
)
View Source
var DefaultWarmUpSchedule = []domain.WarmUpDay{
	{Day: 1, MaxVolume: 100},
	{Day: 2, MaxVolume: 200},
	{Day: 3, MaxVolume: 500},
	{Day: 4, MaxVolume: 1000},
	{Day: 5, MaxVolume: 2000},
	{Day: 6, MaxVolume: 5000},
	{Day: 7, MaxVolume: 10000},
	{Day: 8, MaxVolume: 20000},
	{Day: 9, MaxVolume: 30000},
	{Day: 10, MaxVolume: 40000},
	{Day: 11, MaxVolume: 50000},
	{Day: 12, MaxVolume: 60000},
	{Day: 13, MaxVolume: 70000},
	{Day: 14, MaxVolume: 80000},
}

Default warm-up schedule (14-30 day progression)

View Source
var MajorProviders = []string{
	"gmail.com",
	"googlemail.com",
	"outlook.com",
	"hotmail.com",
	"live.com",
	"yahoo.com",
	"aol.com",
	"icloud.com",
}

Major email providers for block detection

Functions

This section is empty.

Types

type ARFParserService

type ARFParserService struct {
	// contains filtered or unexported fields
}

func NewARFParserService

func NewARFParserService(
	arfRepo repository.ARFReportsRepository,
	eventsRepo repository.EventsRepository,
	alertsRepo repository.AlertsRepository,
	logger *zap.Logger,
) *ARFParserService

func (*ARFParserService) GetARFStats

func (s *ARFParserService) GetARFStats(ctx context.Context, domainName string, days int) (map[string]interface{}, error)

GetARFStats returns ARF complaint statistics for a domain

func (*ARFParserService) GetComplaintRate

func (s *ARFParserService) GetComplaintRate(ctx context.Context, domain string, hours int) (float64, error)

GetComplaintRate returns complaint rate for a domain

func (*ARFParserService) ParseARFReport

func (s *ARFParserService) ParseARFReport(ctx context.Context, rawMessage []byte) (*domain.ARFReport, error)

ParseARFReport parses an ARF complaint report

func (*ARFParserService) ProcessComplaint

func (s *ARFParserService) ProcessComplaint(ctx context.Context, report *domain.ARFReport) error

ProcessComplaint processes an ARF complaint and suppresses the recipient

func (*ARFParserService) ProcessReport

func (s *ARFParserService) ProcessReport(ctx context.Context, report *domain.ARFReport) error

ProcessReport processes a single ARF report (alias for ProcessComplaint)

func (*ARFParserService) ProcessUnprocessed

func (s *ARFParserService) ProcessUnprocessed(ctx context.Context) error

ProcessUnprocessed processes all unprocessed ARF reports (alias for ProcessUnprocessedReports)

func (*ARFParserService) ProcessUnprocessedReports

func (s *ARFParserService) ProcessUnprocessedReports(ctx context.Context) error

ProcessUnprocessedReports processes all unprocessed ARF reports

func (*ARFParserService) StoreReport

func (s *ARFParserService) StoreReport(ctx context.Context, report *domain.ARFReport) error

StoreReport saves an ARF report to the database

type AdaptiveLimiter

type AdaptiveLimiter struct {
	// contains filtered or unexported fields
}

AdaptiveLimiter extends the base rate limiter with reputation awareness

func NewAdaptiveLimiter

func NewAdaptiveLimiter(
	baseLimiter *ratelimit.Limiter,
	scoresRepo repository.ScoresRepository,
	warmUpRepo repository.WarmUpRepository,
	circuitRepo repository.CircuitBreakerRepository,
	logger *zap.Logger,
) *AdaptiveLimiter

NewAdaptiveLimiter creates a new adaptive rate limiter

func (*AdaptiveLimiter) CheckDomain

func (l *AdaptiveLimiter) CheckDomain(ctx context.Context, domain string) (bool, error)

CheckDomain verifies if a domain can send based on reputation, circuit breaker, and warm-up This is the main entry point for SMTP backend to use

func (*AdaptiveLimiter) CheckWarmUpVolume

func (l *AdaptiveLimiter) CheckWarmUpVolume(ctx context.Context, domain string) (current int, max int, exceeded bool, err error)

CheckWarmUpVolume verifies if a domain has exceeded its daily warm-up volume Returns current volume and max allowed

func (*AdaptiveLimiter) GetLimit

func (l *AdaptiveLimiter) GetLimit(ctx context.Context, domain string) (int, error)

GetLimit returns the effective rate limit for a domain based on reputation Returns the maximum messages per hour allowed for this domain

func (*AdaptiveLimiter) RecordSend

func (l *AdaptiveLimiter) RecordSend(ctx context.Context, domain string) error

RecordSend increments the warm-up volume counter for a domain Should be called after successful message send during warm-up

type AlertsService

type AlertsService struct {
	// contains filtered or unexported fields
}

func NewAlertsService

func NewAlertsService(
	alertsRepo repository.AlertsRepository,
	logger *zap.Logger,
) *AlertsService

func (*AlertsService) Acknowledge

func (s *AlertsService) Acknowledge(ctx context.Context, id int64, acknowledgedBy string) error

Acknowledge marks an alert as acknowledged

func (*AlertsService) AcknowledgeAlert

func (s *AlertsService) AcknowledgeAlert(ctx context.Context, id int64, acknowledgedBy string) error

AcknowledgeAlert marks an alert as acknowledged (alias for Acknowledge)

func (*AlertsService) CreateAlert

func (s *AlertsService) CreateAlert(ctx context.Context, alert *domain.ReputationAlert) error

CreateAlert creates a new reputation alert

func (*AlertsService) CreateCircuitBreakerAlert

func (s *AlertsService) CreateCircuitBreakerAlert(ctx context.Context, domainName string, triggerType, reason string) error

CreateCircuitBreakerAlert creates an alert for circuit breaker triggers

func (*AlertsService) CreateDNSFailureAlert

func (s *AlertsService) CreateDNSFailureAlert(ctx context.Context, domainName string, checkType string, details map[string]interface{}) error

CreateDNSFailureAlert creates an alert for DNS validation failures

func (*AlertsService) CreateScoreDropAlert

func (s *AlertsService) CreateScoreDropAlert(ctx context.Context, domainName string, oldScore, newScore int, dropPercentage float64) error

CreateScoreDropAlert creates an alert for reputation score drops

func (*AlertsService) ExportAlertsJSON

func (s *AlertsService) ExportAlertsJSON(ctx context.Context, alerts []*domain.ReputationAlert) ([]byte, error)

ExportAlertsJSON exports alerts to JSON format

func (*AlertsService) GetByDomain

func (s *AlertsService) GetByDomain(ctx context.Context, domainName string, limit, offset int) ([]*domain.ReputationAlert, error)

GetByDomain returns alerts for a specific domain

func (*AlertsService) GetByID

func (s *AlertsService) GetByID(ctx context.Context, id int64) (*domain.ReputationAlert, error)

GetByID retrieves a specific alert

func (*AlertsService) GetBySeverity

func (s *AlertsService) GetBySeverity(ctx context.Context, severity domain.AlertSeverity, limit int) ([]*domain.ReputationAlert, error)

GetBySeverity returns alerts by severity level

func (*AlertsService) GetUnacknowledged

func (s *AlertsService) GetUnacknowledged(ctx context.Context, limit int) ([]*domain.ReputationAlert, error)

GetUnacknowledged returns all unacknowledged alerts

func (*AlertsService) GetUnacknowledgedCount

func (s *AlertsService) GetUnacknowledgedCount(ctx context.Context) (int, error)

GetUnacknowledgedCount returns count of unacknowledged alerts

func (*AlertsService) GetUnacknowledgedCountByDomain

func (s *AlertsService) GetUnacknowledgedCountByDomain(ctx context.Context, domainName string) (int, error)

GetUnacknowledgedCountByDomain returns count of unacknowledged alerts for a domain

func (*AlertsService) Resolve

func (s *AlertsService) Resolve(ctx context.Context, id int64) error

Resolve marks an alert as resolved

func (*AlertsService) ResolveAlert

func (s *AlertsService) ResolveAlert(ctx context.Context, id int64) error

ResolveAlert marks an alert as resolved (alias for Resolve)

type AuditorService

type AuditorService struct {
	// contains filtered or unexported fields
}

AuditorService performs deliverability readiness audits for domains

func NewAuditorService

func NewAuditorService(tlsMgr *tlsManager.Manager, logger *zap.Logger) *AuditorService

NewAuditorService creates a new auditor service

func (*AuditorService) AuditDomain

func (s *AuditorService) AuditDomain(ctx context.Context, domainName string, sendingIP net.IP) (*domain.AuditResult, error)

AuditDomain performs a comprehensive deliverability audit for a domain

type CircuitBreakerService

type CircuitBreakerService struct {
	// contains filtered or unexported fields
}

CircuitBreakerService manages automatic domain pause/resume based on reputation

func NewCircuitBreakerService

func NewCircuitBreakerService(
	eventsRepo repository.EventsRepository,
	scoresRepo repository.ScoresRepository,
	circuitRepo repository.CircuitBreakerRepository,
	telemetry *TelemetryService,
	logger *zap.Logger,
) *CircuitBreakerService

NewCircuitBreakerService creates a new circuit breaker service

func (*CircuitBreakerService) AutoResume

func (s *CircuitBreakerService) AutoResume(ctx context.Context) error

AutoResume attempts to resume domains that have been paused Uses exponential backoff: 1h → 2h → 4h → 8h Should be called periodically (every hour)

func (*CircuitBreakerService) CheckAndTrigger

func (s *CircuitBreakerService) CheckAndTrigger(ctx context.Context) error

CheckAndTrigger evaluates all circuit breaker thresholds and triggers if needed Should be called periodically (every 15 minutes)

func (*CircuitBreakerService) ManualResume

func (s *CircuitBreakerService) ManualResume(ctx context.Context, domainName string, adminNotes string) error

ManualResume allows admin to manually resume a paused domain Bypasses automatic checks

type CustomWarmupService

type CustomWarmupService struct {
	// contains filtered or unexported fields
}

func NewCustomWarmupService

func NewCustomWarmupService(
	warmupRepo repository.CustomWarmupRepository,
	logger *zap.Logger,
) *CustomWarmupService

func (*CustomWarmupService) CreateAggressiveSchedule

func (s *CustomWarmupService) CreateAggressiveSchedule(ctx context.Context, domainName, createdBy string) error

CreateAggressiveSchedule creates an aggressive 14-day warm-up schedule

func (*CustomWarmupService) CreateConservativeSchedule

func (s *CustomWarmupService) CreateConservativeSchedule(ctx context.Context, domainName, createdBy string) error

CreateConservativeSchedule creates a conservative 30-day warm-up schedule

func (*CustomWarmupService) CreateModerateSchedule

func (s *CustomWarmupService) CreateModerateSchedule(ctx context.Context, domainName, createdBy string) error

CreateModerateSchedule creates a moderate 21-day warm-up schedule

func (*CustomWarmupService) CreateSchedule

func (s *CustomWarmupService) CreateSchedule(ctx context.Context, domainName, scheduleName, createdBy string, schedule []*domain.CustomWarmupSchedule) error

CreateSchedule creates a custom warm-up schedule for a domain

func (*CustomWarmupService) DeleteSchedule

func (s *CustomWarmupService) DeleteSchedule(ctx context.Context, domainName string) error

DeleteSchedule deletes a custom schedule

func (*CustomWarmupService) GetSchedule

func (s *CustomWarmupService) GetSchedule(ctx context.Context, domainName string) ([]*domain.CustomWarmupSchedule, error)

GetSchedule retrieves the warm-up schedule for a domain

func (*CustomWarmupService) GetTemplates

func (s *CustomWarmupService) GetTemplates(ctx context.Context) []map[string]interface{}

GetTemplates returns available warmup schedule templates

func (*CustomWarmupService) GetVolumeForDay

func (s *CustomWarmupService) GetVolumeForDay(ctx context.Context, domainName string, day int) (int, error)

GetVolumeForDay returns the max volume for a specific day

func (*CustomWarmupService) ListActiveSchedules

func (s *CustomWarmupService) ListActiveSchedules(ctx context.Context) (map[string][]*domain.CustomWarmupSchedule, error)

ListActiveSchedules returns all active custom schedules

func (*CustomWarmupService) SetActive

func (s *CustomWarmupService) SetActive(ctx context.Context, domainName string, active bool) error

SetActive activates or deactivates a schedule

func (*CustomWarmupService) UpdateSchedule

func (s *CustomWarmupService) UpdateSchedule(ctx context.Context, schedule *domain.CustomWarmupSchedule) error

UpdateSchedule updates an existing schedule

type DMARCActionsService

type DMARCActionsService struct {
	// contains filtered or unexported fields
}

func NewDMARCActionsService

func NewDMARCActionsService(
	actionsRepo repository.DMARCActionsRepository,
	alertsRepo repository.AlertsRepository,
	logger *zap.Logger,
) *DMARCActionsService

func (*DMARCActionsService) ListActions

func (s *DMARCActionsService) ListActions(ctx context.Context, domain string, limit int) ([]*domain.DMARCAutoAction, error)

ListActions returns recent actions for a domain

func (*DMARCActionsService) ListAllActions

func (s *DMARCActionsService) ListAllActions(ctx context.Context, limit, offset int) ([]*domain.DMARCAutoAction, error)

ListAllActions returns all actions with pagination

func (*DMARCActionsService) ProcessAnalysis

func (s *DMARCActionsService) ProcessAnalysis(ctx context.Context, analysis *domain.AlignmentAnalysis) error

ProcessAnalysis processes a full analysis and takes appropriate actions

func (*DMARCActionsService) TakeCorrectiveAction

func (s *DMARCActionsService) TakeCorrectiveAction(ctx context.Context, issue *domain.AlignmentIssue, domainName string) error

TakeCorrectiveAction analyzes an issue and takes automated action

type DMARCAnalyzerService

type DMARCAnalyzerService struct {
	// contains filtered or unexported fields
}

func NewDMARCAnalyzerService

func NewDMARCAnalyzerService(
	reportsRepo repository.DMARCReportsRepository,
	actionsRepo repository.DMARCActionsRepository,
	alertsRepo repository.AlertsRepository,
	logger *zap.Logger,
) *DMARCAnalyzerService

func (*DMARCAnalyzerService) AnalyzeDomain

func (s *DMARCAnalyzerService) AnalyzeDomain(ctx context.Context, domain string, days int) (*domain.AlignmentAnalysis, error)

AnalyzeDomain analyzes all DMARC reports for a domain over a time period

func (*DMARCAnalyzerService) AnalyzeReport

AnalyzeReport performs alignment analysis on a DMARC report

func (*DMARCAnalyzerService) CreateAlert

func (s *DMARCAnalyzerService) CreateAlert(ctx context.Context, analysis *domain.AlignmentAnalysis) error

CreateAlert creates an alert for DMARC issues

type DMARCParserService

type DMARCParserService struct {
	// contains filtered or unexported fields
}

func NewDMARCParserService

func NewDMARCParserService(
	reportsRepo repository.DMARCReportsRepository,
	actionsRepo repository.DMARCActionsRepository,
	logger *zap.Logger,
) *DMARCParserService

func (*DMARCParserService) GetReportByID

func (s *DMARCParserService) GetReportByID(ctx context.Context, id int64) (*domain.DMARCReport, error)

GetReportByID retrieves a specific report with its records

func (*DMARCParserService) GetReportStats

func (s *DMARCParserService) GetReportStats(ctx context.Context, domain string, days int) (*domain.AlignmentAnalysis, error)

GetReportStats returns statistics for a domain's DMARC reports

func (*DMARCParserService) ListReports

func (s *DMARCParserService) ListReports(ctx context.Context, domain string, limit, offset int) ([]*domain.DMARCReport, error)

ListReports returns DMARC reports for a domain with pagination

func (*DMARCParserService) ParseAndStore

func (s *DMARCParserService) ParseAndStore(ctx context.Context, xmlData []byte) error

ParseAndStore combines parsing and storage

func (*DMARCParserService) ParseFromReader

func (s *DMARCParserService) ParseFromReader(ctx context.Context, r io.Reader) (*domain.DMARCReport, error)

ParseFromReader parses DMARC report from an io.Reader

func (*DMARCParserService) ParseReport

func (s *DMARCParserService) ParseReport(ctx context.Context, xmlData []byte) (*domain.DMARCReport, error)

ParseReport parses a DMARC aggregate report from XML

func (*DMARCParserService) StoreReport

func (s *DMARCParserService) StoreReport(ctx context.Context, report *domain.DMARCReport) error

StoreReport saves a parsed report to the database

type GmailPostmasterService

type GmailPostmasterService struct {
	// contains filtered or unexported fields
}

func NewGmailPostmasterService

func NewGmailPostmasterService(
	serviceAccountKey string,
	metricsRepo repository.PostmasterMetricsRepository,
	alertsRepo repository.AlertsRepository,
	logger *zap.Logger,
) (*GmailPostmasterService, error)

func (*GmailPostmasterService) FetchDomainReputation

func (s *GmailPostmasterService) FetchDomainReputation(ctx context.Context, domainName string) (*domain.PostmasterMetrics, error)

FetchDomainReputation retrieves reputation metrics for a domain

func (*GmailPostmasterService) GetLatestMetrics

func (s *GmailPostmasterService) GetLatestMetrics(ctx context.Context, domainName string) (*domain.PostmasterMetrics, error)

GetLatestMetrics returns the latest metrics for a domain

func (*GmailPostmasterService) GetMetricsHistory

func (s *GmailPostmasterService) GetMetricsHistory(ctx context.Context, domainName string, days int) ([]*domain.PostmasterMetrics, error)

GetMetricsHistory returns metrics history for a domain

func (*GmailPostmasterService) GetReputationTrend

func (s *GmailPostmasterService) GetReputationTrend(ctx context.Context, domainName string, days int) ([]string, error)

GetReputationTrend returns domain reputation trend over time

func (*GmailPostmasterService) GetTrends

func (s *GmailPostmasterService) GetTrends(ctx context.Context, domainName string, days int) (map[string]interface{}, error)

GetTrends returns combined trend data for a domain

func (*GmailPostmasterService) SyncAll

func (s *GmailPostmasterService) SyncAll(ctx context.Context, domains []string) error

SyncAll syncs metrics for all configured domains

func (*GmailPostmasterService) SyncDomain

func (s *GmailPostmasterService) SyncDomain(ctx context.Context, domainName string) error

SyncDomain syncs metrics for a single domain

type MicrosoftSNDSService

type MicrosoftSNDSService struct {
	// contains filtered or unexported fields
}

func NewMicrosoftSNDSService

func NewMicrosoftSNDSService(
	apiKey string,
	metricsRepo repository.SNDSMetricsRepository,
	alertsRepo repository.AlertsRepository,
	logger *zap.Logger,
) *MicrosoftSNDSService

func (*MicrosoftSNDSService) FetchIPData

func (s *MicrosoftSNDSService) FetchIPData(ctx context.Context, ipAddress string) (*domain.SNDSMetrics, error)

FetchIPData retrieves reputation metrics for an IP address

func (*MicrosoftSNDSService) GetFilterLevelTrend

func (s *MicrosoftSNDSService) GetFilterLevelTrend(ctx context.Context, ipAddress string, days int) ([]string, error)

GetFilterLevelTrend returns filter level trend over time

func (*MicrosoftSNDSService) GetLatestMetrics

func (s *MicrosoftSNDSService) GetLatestMetrics(ctx context.Context, ipAddress string) (*domain.SNDSMetrics, error)

GetLatestMetrics returns the latest metrics for an IP

func (*MicrosoftSNDSService) GetMetricsHistory

func (s *MicrosoftSNDSService) GetMetricsHistory(ctx context.Context, ipAddress string, days int) ([]*domain.SNDSMetrics, error)

GetMetricsHistory returns metrics history for an IP

func (*MicrosoftSNDSService) GetTrends

func (s *MicrosoftSNDSService) GetTrends(ctx context.Context, ipAddress string, days int) (map[string]interface{}, error)

GetTrends returns combined trend data for an IP address

func (*MicrosoftSNDSService) SyncAll

func (s *MicrosoftSNDSService) SyncAll(ctx context.Context, ipAddresses []string) error

SyncAll syncs metrics for all configured IPs

func (*MicrosoftSNDSService) SyncIP

func (s *MicrosoftSNDSService) SyncIP(ctx context.Context, ipAddress string) error

SyncIP syncs metrics for a single IP address

type PredictionsService

type PredictionsService struct {
	// contains filtered or unexported fields
}

func NewPredictionsService

func NewPredictionsService(
	predictionsRepo repository.PredictionsRepository,
	eventsRepo repository.EventsRepository,
	scoresRepo repository.ScoresRepository,
	logger *zap.Logger,
) *PredictionsService

func (*PredictionsService) GeneratePrediction

func (s *PredictionsService) GeneratePrediction(ctx context.Context, domainName string, horizonHours int) (*domain.ReputationPrediction, error)

GeneratePrediction generates a reputation prediction for a domain

func (*PredictionsService) GeneratePredictions

func (s *PredictionsService) GeneratePredictions(ctx context.Context, domainName string) error

GeneratePredictions generates predictions for a domain (alias for GeneratePrediction with default horizon)

func (*PredictionsService) GeneratePredictionsForAllDomains

func (s *PredictionsService) GeneratePredictionsForAllDomains(ctx context.Context, domains []string, horizonHours int) error

GeneratePredictionsForAllDomains generates predictions for all active domains

func (*PredictionsService) GetLatestPrediction

func (s *PredictionsService) GetLatestPrediction(ctx context.Context, domainName string) (*domain.ReputationPrediction, error)

GetLatestPrediction returns the latest prediction for a domain

func (*PredictionsService) GetPredictionHistory

func (s *PredictionsService) GetPredictionHistory(ctx context.Context, domainName string, limit int) ([]*domain.ReputationPrediction, error)

GetPredictionHistory returns prediction history for a domain

func (*PredictionsService) SetHistoricalScoresRepo

func (s *PredictionsService) SetHistoricalScoresRepo(repo repository.HistoricalScoresRepository)

SetHistoricalScoresRepo sets the historical scores repository for trend analysis

type ProviderRateLimitsService

type ProviderRateLimitsService struct {
	// contains filtered or unexported fields
}

func NewProviderRateLimitsService

func NewProviderRateLimitsService(
	limitsRepo repository.ProviderRateLimitsRepository,
	alertsRepo repository.AlertsRepository,
	logger *zap.Logger,
) *ProviderRateLimitsService

func (*ProviderRateLimitsService) CheckLimit

func (s *ProviderRateLimitsService) CheckLimit(ctx context.Context, domainName string, provider domain.MailProvider) (bool, error)

CheckLimit checks if sending is allowed under current rate limits

func (*ProviderRateLimitsService) CreateOrUpdateLimit

func (s *ProviderRateLimitsService) CreateOrUpdateLimit(ctx context.Context, limit *domain.ProviderRateLimit) error

CreateOrUpdateLimit creates or updates rate limit configuration

func (*ProviderRateLimitsService) GetDomainLimits

func (s *ProviderRateLimitsService) GetDomainLimits(ctx context.Context, domainName string) ([]*domain.ProviderRateLimit, error)

GetDomainLimits returns all provider limits for a domain

func (*ProviderRateLimitsService) GetLimit

GetLimit retrieves rate limit for a domain and provider

func (*ProviderRateLimitsService) IncrementCount

func (s *ProviderRateLimitsService) IncrementCount(ctx context.Context, domainName string, provider domain.MailProvider, count int) error

IncrementCount increments message count for a provider

func (*ProviderRateLimitsService) InitializeDefaultLimits

func (s *ProviderRateLimitsService) InitializeDefaultLimits(ctx context.Context, domainName string) error

InitializeDefaultLimits initializes default rate limits for a domain

func (*ProviderRateLimitsService) InitializeLimits

func (s *ProviderRateLimitsService) InitializeLimits(ctx context.Context, domainName string) error

InitializeLimits initializes default rate limits for a domain (alias for InitializeDefaultLimits)

func (*ProviderRateLimitsService) ResetUsage

func (s *ProviderRateLimitsService) ResetUsage(ctx context.Context, domainName string) error

ResetUsage resets usage counters for a domain's provider limits

func (*ProviderRateLimitsService) SetCircuitBreaker

func (s *ProviderRateLimitsService) SetCircuitBreaker(ctx context.Context, domainName string, provider domain.MailProvider, active bool) error

SetCircuitBreaker activates or deactivates circuit breaker for a provider

type TelemetryService

type TelemetryService struct {
	// contains filtered or unexported fields
}

TelemetryService handles telemetry data collection and aggregation

func NewTelemetryService

func NewTelemetryService(
	eventsRepo repository.EventsRepository,
	scoresRepo repository.ScoresRepository,
	logger *zap.Logger,
) *TelemetryService

NewTelemetryService creates a new telemetry service

func (*TelemetryService) CalculateAllScores

func (s *TelemetryService) CalculateAllScores(ctx context.Context) error

CalculateAllScores calculates reputation scores for all domains

func (*TelemetryService) CalculateReputationScore

func (s *TelemetryService) CalculateReputationScore(ctx context.Context, domainName string) (*domain.ReputationScore, error)

CalculateReputationScore calculates and updates the reputation score for a domain

func (*TelemetryService) CleanupOldData

func (s *TelemetryService) CleanupOldData(ctx context.Context) error

CleanupOldData removes telemetry data older than the retention period

func (*TelemetryService) RecordBounce

func (s *TelemetryService) RecordBounce(
	ctx context.Context,
	domainName, recipientDomain, ip string,
	bounceType, statusCode, response string,
) error

RecordBounce records an email bounce

func (*TelemetryService) RecordComplaint

func (s *TelemetryService) RecordComplaint(ctx context.Context, domainName, recipientDomain string) error

RecordComplaint records a spam complaint

func (*TelemetryService) RecordDelivery

func (s *TelemetryService) RecordDelivery(ctx context.Context, domainName, recipientDomain, ip string) error

RecordDelivery records a successful email delivery

func (*TelemetryService) SetHistoricalScoresRepo

func (s *TelemetryService) SetHistoricalScoresRepo(repo repository.HistoricalScoresRepository)

SetHistoricalScoresRepo sets the historical scores repository for trend tracking

type WarmUpService

type WarmUpService struct {
	// contains filtered or unexported fields
}

WarmUpService manages domain and IP warm-up schedules

func NewWarmUpService

func NewWarmUpService(
	eventsRepo repository.EventsRepository,
	scoresRepo repository.ScoresRepository,
	warmUpRepo repository.WarmUpRepository,
	telemetry *TelemetryService,
	logger *zap.Logger,
) *WarmUpService

NewWarmUpService creates a new warm-up service

func (*WarmUpService) AdvanceWarmUp

func (s *WarmUpService) AdvanceWarmUp(ctx context.Context) error

AdvanceWarmUp moves domains to the next day in their warm-up schedule Should be called daily (at midnight or similar)

func (*WarmUpService) CompleteWarmUp

func (s *WarmUpService) CompleteWarmUp(ctx context.Context, domainName string) error

CompleteWarmUp marks warm-up as finished for a domain

func (*WarmUpService) DetectNewDomains

func (s *WarmUpService) DetectNewDomains(ctx context.Context) error

DetectNewDomains identifies domains that need warm-up Should be called periodically (daily) to catch new sending domains

func (*WarmUpService) GetWarmUpStatus

func (s *WarmUpService) GetWarmUpStatus(ctx context.Context, domainName string) (*domain.WarmUpStatus, error)

GetWarmUpStatus returns the current warm-up status for a domain

func (*WarmUpService) ManualComplete

func (s *WarmUpService) ManualComplete(ctx context.Context, domainName string, adminNotes string) error

ManualComplete allows admin to manually complete warm-up

func (*WarmUpService) StartWarmUp

func (s *WarmUpService) StartWarmUp(ctx context.Context, domainName string, schedule []domain.WarmUpDay) error

StartWarmUp initiates warm-up schedule for a domain

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL