ecto_facade v0.2.1 EctoFacade.Repo

Facade repository that should be used for all operations regarding ecto.

It forwards all write/update/delete operations to master_repo and do all read operations on one of read_repos - which read repository is depending on the algorithm.

Should be used as: use EctoFacade.Repo, master_repo: MyApp.Repo,

read_repos: [MyApp.ReadRepoOne, MyApp.ReadRepoTwo],
algorithm: MyApp.CustomReadRepoAlgorithm
fallback_to_master: false

Possible options:

  • master_repo - only option that is required, it should be main ecto repository used for writes (and reads if you use only one ecto repository)
  • read_repos - (optional) list of repositories that should be used for read operations. Defaults to [master_repo].
  • algorithm - (optional) Module that adhere to EctoFacade.Algorithm behaviour. Defaults to EctoFacade.Algorithms.Random
  • fallback_to_master - (optional) When no read repository is present, should query fallback to master repo (default: true)