All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.enodeframework.commanding.CommandBus.kt Maven / Gradle / Ivy

package org.enodeframework.commanding

import org.enodeframework.queue.SendMessageResult
import java.util.concurrent.CompletableFuture

/**
 * Represents a command service.
 */
interface CommandBus {
    /**
     * Send a command asynchronously.
     *
     * @param command The command to send.
     * @return A task which contains the send result of the command.
     */
    fun sendAsync(command: CommandMessage): CompletableFuture

    /**
     * Send a command synchronously.
     */
    suspend fun send(command: CommandMessage): SendMessageResult

    /**
     * Execute a command asynchronously with the default command return type.
     *
     * @param command The command to execute.
     * @return A task which contains the result of the command.
     */
    fun executeAsync(command: CommandMessage): CompletableFuture

    /**
     * Execute a command asynchronously with the default command return type.
     */
    suspend fun execute(command: CommandMessage): CommandResult

    /**
     * Execute a command asynchronously with the specified command return type.
     *
     * @param command           The command to execute.
     * @param commandReturnType The return type of the command.
     * @return A task which contains the result of the command.
     */
    fun executeAsync(command: CommandMessage, commandReturnType: CommandReturnType): CompletableFuture

    /**
     * Execute a command synchronously with the specified command return type.
     */
    suspend fun execute(command: CommandMessage, commandReturnType: CommandReturnType): CommandResult
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy