You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.0 KiB
Kotlin
40 lines
1.0 KiB
Kotlin
package wf.servitor.common.config
|
|
|
|
import com.uchuhimo.konf.source.toml
|
|
import com.uchuhimo.konf.Config.Companion as KonfConfig
|
|
|
|
fun createConfig(file: String? = null): Config {
|
|
val config = run {
|
|
var config = KonfConfig {
|
|
addSpec(QueueSpec)
|
|
}
|
|
.from.toml.file("/etc/servitor/config.toml", optional = true)
|
|
.from.json.file("/etc/servitor/config.json", optional = true)
|
|
|
|
if (file !== null) {
|
|
config = if (file.endsWith("json")) {
|
|
config.from.json.file(file)
|
|
} else {
|
|
config.from.toml.file(file)
|
|
}
|
|
}
|
|
|
|
config
|
|
}
|
|
|
|
return Config(
|
|
Queue(
|
|
config[QueueSpec.url],
|
|
config[QueueSpec.username],
|
|
config[QueueSpec.password],
|
|
Queue.Names(
|
|
config[QueueSpec.Names.namePrefix],
|
|
config[QueueSpec.Names.task],
|
|
config[QueueSpec.Names.relay],
|
|
config[QueueSpec.Names.observation]
|
|
)
|
|
)
|
|
|
|
)
|
|
}
|