abhir2020
Ecto runtime repo creation
Hi,
I am working to setup postgres adapter with ecto on Amazon Aurora. So i have writer and read databases. So i would like to use read_replica for report generations and extend my services for different activities in future.
Planning that, I wanted my application to start Dynamic Repo, connecting to databases in runtime(based on configuration during node startup). So instead of using dynamic repos approach, I am trying to compile at runtime, the read_repos during application startup.
Code.compile_string(“defmodule #{repo} do \n use Ecto.Repo, otp_app: :web_api, adapter: Ecto.Adapters.Postgres, read_only: true \nend”(h))
and attaching the module repo in the supervisor.
This looks simple. But what could be the complication in following this approach?.
Thanks in advance.
First Post!
hauleth
Why not use dynamic repos instead? Dynamic code compilation is something that should be avoided unless you are 100% sure that you will need it (and believe me, in this case you do not need it).
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
- #javascript
- #podcasts
- #code-sync
- #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








