abhir2020
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.
Trending in Discussions
Other Trending Topics
Latest Phoenix Threads
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
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #phoenix_html
- #elixirconf-us
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 2- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
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).
abhir2020
Thanks for your quick response @hauleth
Basically I want both database servers to be active. One database is a read_only database and other is a writer/reader database. In future if I want another database server, I should be in a place to add a new read_database to list. Is this possible with dynamic repos?.