Skip to content

Command Sender

Outbound port for asynchronously sending commands.

This module defines a CommandSender, an application-layer abstraction for
dispatching commands via an external message bus. It decouples command
issuance from transport details and message broker implementations.

Responsibilities:
- Forward commands to an injected MessageBus.
- Abstract message dispatch mechanism.

Non-Responsibilities:
- Delivery guarantees (at-least-once, ordering, retries).
- Serialization or transport concerns.

command_sender

Outbound port for asynchronously sending commands.

This module defines a CommandSender, an application-layer abstraction for
dispatching commands via an external message bus. It decouples command
issuance from transport details and message broker implementations.

Responsibilities
  • Forward commands to an injected MessageBus.
  • Abstract message dispatch mechanism.
Non-Responsibilities
  • Delivery guarantees (at-least-once, ordering, retries).
  • Serialization or transport concerns.

CommandSender

Bases: OutboundPort[Command, None]

Outbound port for asynchronously sending command messages.

The CommandSender delegates message dispatching to a MessageBus. It is
typically used by use cases or handlers that need to trigger command-side
operations in other parts of the system.

Source code in src/forging_blocks/application/ports/outbound/command_sender.py
class CommandSender(OutboundPort[Command, None]):
    """Outbound port for asynchronously sending command messages.

    The CommandSender delegates message dispatching to a MessageBus. It is
    typically used by use cases or handlers that need to trigger command-side
    operations in other parts of the system.
    """

    def __init__(self, message_bus: MessageBus[Command, None]) -> None:
        self._message_bus = message_bus

    async def send(self, command: Command) -> None:
        """Send a command asynchronously.

        Args:
            command: The command instance to dispatch.

        Notes:
            - This operation is fire-and-forget from the application's
              perspective.
            - Delivery semantics depend on the underlying MessageBus
              implementation.
        """
        await self._message_bus.dispatch(command)

send(command: Command) -> None async

Send a command asynchronously.

Parameters:

Name Type Description Default
command Command

The command instance to dispatch.

required
Notes
  • This operation is fire-and-forget from the application's
    perspective.
  • Delivery semantics depend on the underlying MessageBus
    implementation.
Source code in src/forging_blocks/application/ports/outbound/command_sender.py
async def send(self, command: Command) -> None:
    """Send a command asynchronously.

    Args:
        command: The command instance to dispatch.

    Notes:
        - This operation is fire-and-forget from the application's
          perspective.
        - Delivery semantics depend on the underlying MessageBus
          implementation.
    """
    await self._message_bus.dispatch(command)