-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update docs + local dev fixes. (#47)
* config: configure `SQConnectors` at runtime in prod. * docs: update README and remove legacy TODO. * Updates the README with new brand and better instructions. * Update config/runtime.exs Co-authored-by: Ilia Borovitinov <[email protected]>
- Loading branch information
1 parent
1e728f6
commit 724f921
Showing
3 changed files
with
62 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,83 @@ | ||
<a href="https://electric-sql.com"> | ||
<picture> | ||
<source media="(prefers-color-scheme: dark)" | ||
srcset="https://raw.githubusercontent.com/electric-sql/meta/main/identity/ElectricSQL-logo-light-trans.svg" | ||
/> | ||
<source media="(prefers-color-scheme: light)" | ||
srcset="https://raw.githubusercontent.com/electric-sql/meta/main/identity/ElectricSQL-logo-black.svg" | ||
/> | ||
<img alt="ElectricSQL logo" | ||
src="https://raw.githubusercontent.com/electric-sql/meta/main/identity/ElectricSQL-logo-black.svg" | ||
/> | ||
</picture> | ||
</a> | ||
|
||
# Electric | ||
|
||
This is a POC of Postgres active-active replication using Vaxine. | ||
This is the replication service for [ElectricSQL](https://electric-sql.com). | ||
|
||
It's an Elixir application that integrates with Postgres over logical replication and Satellite (ElectricSQL's client-side replication component that works with SQLite) via a web socket interface. | ||
|
||
## Pre-reqs | ||
|
||
Docker and Elixir 1.13. | ||
|
||
## Run databases | ||
## Usage | ||
|
||
See the [Makefile](./Makefile) for usage. Setup using: | ||
|
||
```sh | ||
docker-compose -f databases.yaml up | ||
make deps compile | ||
``` | ||
|
||
## Run app | ||
Run the dependencies using: | ||
|
||
```sh | ||
mix run --no-halt | ||
make start_dev_env | ||
``` | ||
|
||
## Generate workload | ||
Run the tests: | ||
|
||
```sh | ||
make tests | ||
``` | ||
|
||
For now, manually issue some SQL statements, e.g.: | ||
And then develop using: | ||
|
||
```sh | ||
make shell | ||
``` | ||
psql -h localhost -p 54321 -U electric -d electric | ||
... | ||
electric=# INSERT INTO entries (content) VALUES ('a'); | ||
electric=# select * from entries; | ||
electric=# update entries set content = 'b'; | ||
|
||
This runs active-active replication with Postgres over logical replication and exposes a protocol buffers API over web sockets on `localhost:30002` for the ElectricSQL client libraries. | ||
|
||
For example to write some data into one of the Postgres instances: | ||
|
||
```sh | ||
docker exec -it -e PGPASSWORD=password electric_db_a_1 psql -h 127.0.0.1 -U electric -d electric | ||
``` | ||
|
||
Then view the app logs, should look a bit like: | ||
There's a second instance, `electric-db_b_1`, if you want to see data being replicated between them. | ||
|
||
## OSX | ||
|
||
Note that if, when running on OSX, you get errors like: | ||
|
||
``` | ||
{:message, | ||
%Broadway.Message{ | ||
acknowledger: {Electric.Replication, :ack_id, {#PID<0.218.0>, {0, 24336352}}}, | ||
batch_key: :default, | ||
batch_mode: :bulk, | ||
batcher: :default, | ||
data: %Electric.Replication.Changes.Transaction{ | ||
changes: [ | ||
%Electric.Replication.Changes.NewRecord{ | ||
record: %{ | ||
"content" => "a", | ||
"id" => "9be3b616-17e9-4264-9f33-5bdb36c48443" | ||
}, | ||
relation: {"public", "entries"} | ||
} | ||
], | ||
commit_timestamp: ~U[2022-06-01 14:07:56Z] | ||
}, | ||
metadata: %{}, | ||
status: :ok | ||
}} | ||
{:ack, {0, 24336352}} | ||
{:message, | ||
%Broadway.Message{ | ||
acknowledger: {Electric.Replication, :ack_id, {#PID<0.218.0>, {0, 24336568}}}, | ||
batch_key: :default, | ||
batch_mode: :bulk, | ||
batcher: :default, | ||
data: %Electric.Replication.Changes.Transaction{ | ||
changes: [ | ||
%Electric.Replication.Changes.UpdatedRecord{ | ||
old_record: %{ | ||
"content" => "a", | ||
"id" => "9be3b616-17e9-4264-9f33-5bdb36c48443" | ||
}, | ||
record: %{ | ||
"content" => "b", | ||
"id" => "9be3b616-17e9-4264-9f33-5bdb36c48443" | ||
}, | ||
relation: {"public", "entries"} | ||
} | ||
], | ||
commit_timestamp: ~U[2022-06-01 14:08:39Z] | ||
}, | ||
metadata: %{}, | ||
status: :ok | ||
}} | ||
could not connect to the publisher: connection to server at \"host.docker.internal\" (192.168.65.2), port 5433 failed | ||
``` | ||
|
||
Note the `old_record` as well as the `new_record`. | ||
You may need to adjust your docker networking or run Electric within docker. To run within Docker, you can build the docker image locally: | ||
|
||
```sh | ||
make docker-build | ||
``` | ||
|
||
And then run with the right env vars, e.g.: | ||
|
||
```sh | ||
docker run -it -p "5433:5433" -p "5133:5133" \ | ||
-e "VAXINE_HOSTNAME=host.docker.internal" | ||
-e "ELECTRIC_HOST=host.docker.internal" | ||
-e "CONNECTORS=pg1=postgresql://electric:[email protected]:54321/electric;pg2=postgresql://electric:[email protected]:54322/electric" \ | ||
docker.io/library/electric:local-build | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters