Skip to content

Add example of using library with Ecto #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ config :libcluster,
Then add it to your supervision tree:

```elixir
defmodule MyApp do
defmodule MyApp.Application do
use Application

def start(_type, _args) do
Expand All @@ -74,6 +74,31 @@ defmodule MyApp do
end
end
```

If you are using Ecto, you may want to reuse your existing repo
configuration. For example:

```elixir
defmodule MyApp.Application do
use Application

def start(_type, _args) do
topology = [
strategy: LibclusterPostgres.Strategy,
config: MyApp.Repo.config()
]

children = [
# ...
{Cluster.Supervisor, [[app: topology]]},
# ...
]

Supervisor.start_link(children, strategy: :one_for_one)
end
end
```

### Why do we need a distributed Erlang Cluster?

At Supabase, we use clustering in all of our Elixir projects which include [Logflare](https://github.com/Logflare/logflare), [Supavisor](https://github.com/supabase/supavisor) and [Realtime](https://github.com/supabase/realtime). With multiple servers connected we can load shed, create globally distributed services and provide the best service to our customers so we’re closer to them geographically and to their instances, reducing overall latency.
Expand Down