我有一个关于六边形架构和 DDD 的问题
是否允许从作为参数传递给适配器的持久性适配器调用域逻辑?
例子:
class DomainService(private val repositoryPort: RepositoryPort,
private val domainService2: DomainService2) {
fun doSomething(id: String?) {
repositoryPort.doSomething(id) {
id: String? ->
domainService2.doSomething2(id)
}
println("Doing something")
}
}
class DomainService2 {
fun doSomething2(id: String?) {
println("Doing something$id")
}
}
interface RepositoryPort {
fun doSomething(id: String?, consumer: (id: String?) -> Unit)
}
class RepositoryAdapter : RepositoryPort {
override fun doSomething(id: String?, consumer: (id: String?) -> Unit) {
println("checking something, searching in database")
consumer.invoke(id) // Is it allow here to call domain again ?
}
}