// Package notification_retry runs the async notification retry worker in-process. package notification_retry import ( "context" "sync" "gateway/internal/model/notification/usecase" ) // Runner starts and stops the notification RetryWorker. type Runner struct { worker *usecase.RetryWorker wg sync.WaitGroup } // NewRunner wraps a RetryWorker for lifecycle management. func NewRunner(worker *usecase.RetryWorker) *Runner { if worker == nil { return nil } return &Runner{worker: worker} } // Start launches worker goroutines until ctx is cancelled. func (r *Runner) Start(ctx context.Context) { if r == nil || r.worker == nil { return } r.wg.Add(1) go func() { defer r.wg.Done() r.worker.Run(ctx) }() } // Stop waits for workers to exit after context cancellation. func (r *Runner) Stop() { if r == nil { return } r.wg.Wait() }