woohaaha
Blog post on "Piping Phoenix Contexts", has anyone tried this and can give their experience?
I came across this blog post: https://iacobson.medium.com/piping-phoenix-contexts-3d54dbba8df9
I really like the idea and was wondering if anyone else in the community had thoughts and/or experience with this sort of implementation?
For context (
) I have a Phoenix app with 10 contexts (each with variable numbers of models/schemas 2-10 each). I think the contexts are correct as it feels very intuitive and the terminology makes sense (at least for me) but I’m coming across issues where more and more features require multiple contexts to be called. Easiest example I think to understand would be the New User Onboarding requires:
Account.create_user
Organizaton.join
Analytics.track_create_user
Notifications.send_pending_membership_email
Notifications.send_admin_approval_email
+ a few more
I think this blog post describes a process that may make sense as the application grows but I’d like some feedback from people who have experience in this area.
Thank you
First Post!
joaquinalcerro
Depending in your final goals, you can check this options:
- The token approach: Advanced Techniques for Architecting Flow in Elixir · rrrene
- Ecto Multi: Ecto.Multi — Ecto v3.14.0
For the Ecto Multi option, you can wrap all those functions in a transaction Repo.transaction allowing you to handle a use case if one of the operations fail. Maybe rollback or take other actions.
Check the Multi.run function: Ecto.Multi — Ecto v3.14.0
I have used them both.
Popular in Discussions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









