org.enodeframework.commanding.CommandContext.kt Maven / Gradle / Ivy
package org.enodeframework.commanding
import org.enodeframework.domain.AggregateRoot
import org.enodeframework.messaging.ApplicationMessage
import java.util.concurrent.CompletableFuture
interface CommandContext {
/**
* Add a new aggregate into the current command context.
*/
suspend fun add(aggregateRoot: AggregateRoot)
/**
* Add a new aggregate into the current command context synchronously, and then return a completed task object.
*/
fun addAsync(aggregateRoot: AggregateRoot): CompletableFuture
/**
* Get an aggregate sync from the current command context.
*/
suspend fun get(id: String, firstFromCache: Boolean, aggregateRootType: Class): T
/**
* Get an aggregate async from the current command context.
*/
fun getAsync(
id: String,
firstFromCache: Boolean,
aggregateRootType: Class
): CompletableFuture
/**
* Get an aggregate sync from the current command context, default from cache.
*/
suspend fun get(id: String, aggregateRootType: Class): T
/**
* Get an aggregate async from the current command context, default from cache.
*/
fun getAsync(id: String, aggregateRootType: Class): CompletableFuture
/**
* Get result.
*/
var result: String
/**
* Set an application message.
*/
var applicationMessage: ApplicationMessage?
}