lato
lato copied to clipboard
A command should be registered only by one handler
In the context of CQRS, a command should typically be handled by only one command handler per bounded context/module. However, it seems that this is not the case in the current implementation. Is this intentional? Ideally I would expect to raise an error on the registration.
from lato import Application, ApplicationModule, Command
class C(Command): ...
app = Application(name="App")
module_a = ApplicationModule("Module A")
app.include_submodule(module_a)
@module_a.handler(C)
def handler_a1(cmd: C):
print("module_a1")
@module_a.handler(C)
def handler_a2(cmd: C):
print("module_a2")
Prints:
module_a1
module_a2
Hi @chkoar, You are absolutely right. There should be only one command handler per module, I can fix this in a next release. Thanks for reporting.