CQRS/ES premiere for notifications system

69 views
Skip to first unread message

yevheni...@gmail.com

unread,
May 29, 2016, 11:46:14 PM5/29/16
to elixir-lang-talk
Hello,

There is a great article about using CQRS/ES in Elixir/Phoenix http://jfcloutier.github.io/jekyll/update/2015/11/04/cqrs_elixir_phoenix.html which inspired us to try those technics in our app.

I'm sure that it's a very common pattern in reappearing situation (everyone are building notifications in Elixir!) and should be pretty straightforward to implement, but as an n00b, I have a lot of questions, besides the fact that I might not have a correct understanding of it at all.  

So we have three sets:
Notification Events - transactional and domain (registration, password reset, doing a post, etc)
Notification Channels  - currently email and SMS
Users who have contacts info in their profiles

Assumed OTP structure: 
NotificationManager is a notifications operations entry point, it's a supervised GenServer (https://domnikl.github.io/supervised-gen-event/)  that  orchestrates notification dispatching. Each Notification Channel thus   is a handler implementing GenEvent behavior on the Notification Manager.
NotificationManager then exposes simple API (details are still under consideration) like notify(:event_name, %User{}, channels \\ [:all], additional_message \\ "")  and calls subsequent handlers each in separate process (????) to parallelize notifications delivery. 
Handlers in their turn are just hitting other application services that perform a real job. 

Afterward, NotificationManager caller is notified of the operations results (delivered or not delivered, if not - there must be a detail to show it to the user).

Questions here:

1. Is it a Frankenstein style over-engineering? Am I trying to shoot myself in the foot? 
2. At which point NotificationHandlers should be spawned to make notifications dispatched in parallel? Besides costly network IO operations, they will also need to query database for the provided message templates.
3. How to communicate operations results to the NotificationManager caller?

Super thrived to work with OTP and implement it the "right-way"(tm)


Reply all
Reply to author
Forward
0 new messages