akhundMurad / diator

Diator is a Python library for implementing CQRS pattern in your Python applications.
https://akhundmurad.github.io/diator/
MIT License
61 stars 6 forks source link

Question: Will Python Dependency Injection framework be supported? #26

Closed a4tarasiuk closed 1 year ago

a4tarasiuk commented 1 year ago

Is it possible to add support for https://python-dependency-injector.ets-labs.org/ ? Or maybe there are some concerns about why it is not used?

akhundMurad commented 1 year ago

Hello! It is definitely possible to implement. Will try to add to the upcoming release.

a4tarasiuk commented 1 year ago

Hello! It is definitely possible to implement. Will try to add to the upcoming release.

Thanks! Great!

Also, have a question: Is diator is async only because of di package? I do not see any async operations except of resolving dependencies via async executor in di package. Is it possible to port diator to sync mode?

If there is something I can do, please, just tell me.

a4tarasiuk commented 1 year ago

Also, have a few more questions not related to this topic, just do not wanna create many issues. Is there any road map for development? Very interesting the content of the next releases. There are interesting components (like NotificationEvent) which are cannot be used now (if I clearly understood everything from docs and code), and it would be nice to know when they are planned to be supported etc.

akhundMurad commented 1 year ago
  1. Sure, you can read CONTRIBUTING.MD to understand how to setup and modify project.
  2. All types of events are fully supported and ready to use. Is there any particular issue you faced?
a4tarasiuk commented 1 year ago

Yeah, got typing issue during creating handler for NotificationEvent. Mypy throws an error, because of generic of EventHandler event type (TypeVar("E", bound=DomainEvent, contravariant=True)) is bound to DomainEvent, while NotificationEvent is just Event. The same for ECSTEvent.

EventHandler requires only DomaintEvent based events.

akhundMurad commented 1 year ago

Unfortunately, there are several places where mypy throws this kind of error. Thanks for sharing, I will include it to the next release. Planning to start work on it on the weekends!

akhundMurad commented 1 year ago

Sorry, I read your comment second time. EventHandler accepts only DomainEvent because it is designed in order to handle only business logic. Whereas, notification and ECST events are sent asynchronously to the message broker. Afterwards, it could be handled by other services (consumers). Hope I described clearly :)

a4tarasiuk commented 1 year ago

Oh, yeah, got it! Thanks for the explanation.

a4tarasiuk commented 1 year ago

Also, could you please answer this one - https://github.com/akhundMurad/diator/issues/26#issuecomment-1708943177

akhundMurad commented 1 year ago

Diator is async only. Probably, in the far future it will have support of the sync mode