Skip to content

Chapter 13. Dependency Injection use same uow concurrently in entrypoint? #69

@wyg031113

Description

@wyg031113

booststrap script bind same uow to all handlers? Every request use same uow object. Should we create uow on every http request/or every event/every command ?
UoW is consistent boundary, it commit changes after one handler. but now, concurrent committing concurrently will broke it?


def bootstrap(
    start_orm: bool = True,
    uow: unit_of_work.AbstractUnitOfWork = unit_of_work.SqlAlchemyUnitOfWork(), #sameobject
    notifications: AbstractNotifications = None,
    publish: Callable = redis_eventpublisher.publish,
) -> messagebus.MessageBus:

class MessageBus:
    def __init__(
        self,
        uow: unit_of_work.AbstractUnitOfWork,
        event_handlers: Dict[Type[events.Event], List[Callable]],
        command_handlers: Dict[Type[commands.Command], Callable],
    ):
        self.uow = uow  #sameobject
        self.event_handlers = event_handlers
        self.command_handlers = command_handlers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions