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).
Last Post!
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?.
Popular in Discussions
Other popular topics
Latest Phoenix Threads
Chat & Discussions>Discussions
Latest on Elixir Forum
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
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









