abhir2020

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

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

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?.

Where Next?

Popular in Discussions Top

PragTob
Hey everyone, this has been on my mind for some time and I’d love your input on it! TLDR: I feel like maps are superioer for storing and...
New
rower687
Hi all, I’ve been reading a lot about the “let it crash” term and how supervising processes and the whole messaging passing make an elixi...
New
PragTob
Hey everyone, this has been brewing in my head some time and it came up again while reading Adopting Elixir. GenServers, supervisors et...
New
PragTob
Hello everyone, I know we had quite some threads (read through lots of them) about background job processing but it remains a hotly deba...
New
tomekowal
Hey guys! I want to create a toy project that shows a chart of temperature over time and updates every 5 seconds. I feel LiveView is per...
New
Fl4m3Ph03n1x
Background This question comes mainly from my ignorance. Today is Black Friday, one of my favorite days of the year to buy books. One boo...
New
nunobernardes99
Hi there Elixir friends :vulcan_salute: In a recent task I was on, I needed to check in two dates which of them is the maximum and which...
New

Other popular topics Top

hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

We're in Beta

About us Mission Statement