Skip to content

Instantly share code, notes, and snippets.

@adamw
Created July 16, 2019 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamw/fcc0016fde3c7a13d9c0e65360af5e7c to your computer and use it in GitHub Desktop.
Save adamw/fcc0016fde3c7a13d9c0e65360af5e7c to your computer and use it in GitHub Desktop.
trait EmailModule extends BaseModule {
lazy val emailService = new EmailService(idGenerator, emailSender, config.email, xa)
// the EmailService implements the EmailScheduler functionality - hence, creating
// an alias for this dependency
lazy val emailScheduler: EmailScheduler = emailService
lazy val emailTemplates = new EmailTemplates()
// depending on the configuration, creating the appropriate EmailSender instance
lazy val emailSender: EmailSender = if (config.email.mailgun.enabled) {
new MailgunEmailSender(config.email.mailgun)(sttpBackend)
} else if (config.email.smtp.enabled) {
new SmtpEmailSender(config.email.smtp)
} else {
DummyEmailSender
}
def xa: Transactor[Task]
def sttpBackend: SttpBackend[Task, Nothing]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment