You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DependencyInjectionModule.scala 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package de.codingchallenge
  2. import akka.actor.ActorSystem
  3. import akka.stream.ActorMaterializer
  4. import com.softwaremill.macwire._
  5. import fr.davit.akka.http.prometheus.scaladsl.server.HttpMetricsExports
  6. import fr.davit.akka.http.prometheus.scaladsl.server.settings.HttpMetricsSettings
  7. import de.codingchallenge.configuration.{AkkaConfigurator, Environment}
  8. import de.codingchallenge.logging.LoggingModule
  9. import de.codingchallenge.models.ProductExport
  10. import de.codingchallenge.repositories.{ArticleRepository, ProductExportRepository}
  11. import de.codingchallenge.services.ArticleExportService
  12. import io.prometheus.client.CollectorRegistry
  13. import scala.concurrent.ExecutionContext
  14. trait DependencyInjectionModule extends LoggingModule {
  15. implicit val ec: ExecutionContext = ExecutionContext.global
  16. lazy val environment = wire[Environment]
  17. lazy val routes = wire[Routes]
  18. lazy val akkaConfigurator = wire[AkkaConfigurator]
  19. def actorSystem: ActorSystem
  20. def actorMaterializer: ActorMaterializer
  21. // the custom prometheus registry that you use in your app
  22. val customCollectorRegistry = CollectorRegistry.defaultRegistry
  23. val httpMetricsExports = new HttpMetricsExports {
  24. override val registry = customCollectorRegistry
  25. }
  26. implicit val httpMetricsSettings = HttpMetricsSettings(
  27. exports = httpMetricsExports)
  28. lazy val articleRepository = wire[ArticleRepository]
  29. lazy val exportService = wire[ArticleExportService]
  30. lazy val productExportRepo = wire[ProductExportRepository]
  31. }