1 /* 2 * Make.org Core API 3 * Copyright (C) 2018 Make.org 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU Affero General Public License as 7 * published by the Free Software Foundation, either version 3 of the 8 * License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Affero General Public License for more details. 14 * 15 * You should have received a copy of the GNU Affero General Public License 16 * along with this program. If not, see <https://www.gnu.org/licenses/>. 17 * 18 */ 19 20 package org.make.api.extensions 21 22 import akka.actor.typed.{ActorSystem, Extension, ExtensionId} 23 import com.typesafe.config.Config 24 import org.make.api.technical.ActorSystemComponent 25 26 class KafkaConfiguration(override protected val configuration: Config) extends Extension with ConfigurationSupport { 27 28 val connectionString: String = configuration.getString("connection-string") 29 def topic(name: String): String = configuration.getString(s"topics.$name") 30 31 val pollTimeout: Long = configuration.getLong("poll-timeout") 32 val schemaRegistry: String = configuration.getString("schema-registry") 33 34 } 35 36 object KafkaConfiguration extends ExtensionId[KafkaConfiguration] { 37 override def createExtension(system: ActorSystem[_]): KafkaConfiguration = 38 new KafkaConfiguration(system.settings.config.getConfig("make-api.kafka")) 39 } 40 41 trait KafkaConfigurationComponent { 42 def kafkaConfiguration: KafkaConfiguration 43 } 44 45 trait DefaultKafkaConfigurationComponent extends KafkaConfigurationComponent { this: ActorSystemComponent => 46 override lazy val kafkaConfiguration: KafkaConfiguration = KafkaConfiguration(actorSystem) 47 }
| Line | Stmt Id | Pos | Tree | Symbol | Tests | Code |
|---|---|---|---|---|---|---|
| 28 | 6957 | 1077 - 1121 | Apply | com.typesafe.config.Config.getString | KafkaConfiguration.this.configuration.getString("connection-string") | |
| 29 | 6140 | 1158 - 1198 | Apply | com.typesafe.config.Config.getString | KafkaConfiguration.this.configuration.getString(("topics.".+(name): String)) | |
| 31 | 7484 | 1226 - 1263 | Apply | com.typesafe.config.Config.getLong | KafkaConfiguration.this.configuration.getLong("poll-timeout") | |
| 32 | 6692 | 1295 - 1337 | Apply | com.typesafe.config.Config.getString | KafkaConfiguration.this.configuration.getString("schema-registry") | |
| 38 | 6206 | 1514 - 1564 | Apply | com.typesafe.config.Config.getConfig | system.settings.config.getConfig("make-api.kafka") | |
| 38 | 7632 | 1491 - 1565 | Apply | org.make.api.extensions.KafkaConfiguration.<init> | new KafkaConfiguration(system.settings.config.getConfig("make-api.kafka")) |