diff --git a/website/docs/api/clients/elixir.md b/website/docs/api/clients/elixir.md index 7502aa30ba..391d3643e2 100644 --- a/website/docs/api/clients/elixir.md +++ b/website/docs/api/clients/elixir.md @@ -4,22 +4,38 @@ outline: deep # Elixir Client -The Elixir client is being developed in [electric-sql/electric-next/pull/38](https://github.com/electric-sql/electric-next/pull/38). At the moment it provides a GenStage producer that can be used to stream a Shape as per: +We [maintain an Elixir +client](https://github.com/electric-sql/electric/tree/main/packages/elixir-client) +that will stream messages from an Electric server. + +## Install + +You can install it from [Hex](https://hex.pm/electric_client). + +## How to use + +The client exposes a +[`stream/3`](https://hexdocs.pm/electric_client/Electric.Client.html#stream/3) +function that returns an +[`Enumerable`](https://hexdocs.pm/elixir/Enumerable.html). ```elixir -opts = [ - base_url: "http://...", - shape_definition: %Electric.Client.ShapeDefinition{ - table: "..." - } -] +Mix.install([:electric_client]) -{:ok, pid, stream} = Electric.Client.ShapeStream.stream(opts) +{:ok, client} = Electric.Client.new(base_url: "http://localhost:3000") + +stream = Electric.Client.stream(client, "my_table", where: "something = true") stream |> Stream.each(&IO.inspect/1) |> Stream.run() ``` -See the [shape_stream_test.exs](https://github.com/electric-sql/electric-next/blob/thruflo/elixir-client/elixir_client/test/electric/client/shape_stream_test.exs) for more details. +It also has an [`Ecto`](https://hexdocs.pm/ecto) integration that will generate +updates based on an `Ecto` query: + +```elixir +stream = Electric.Client.stream(client, from(t in MyTable, where: t.something == true)) +``` +See the [client documentation](https://hexdocs.pm/electric_client) for more details.