Skip to content

Commit

Permalink
Simplify pubsub dev instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
tompave committed Jul 23, 2023
1 parent 24b12e7 commit 490a6be
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -820,11 +820,10 @@ When using `Phoenix.PubSub` (which is typically the case with `Ecto`), then the

Steps:

1. Ensure you've cleared previously build artifacts with `rm -rf _build/dev/lib/fun_with_flags/`.
2. Run `bin/console_ecto --name foo` in one terminal.
3. Run `bin/console_ecto --name bar` in another terminal.
4. In either terminal, grab the current name with `Node.self()`. (The name will also be shown in the `iex` prompts).
5. In the other terminal, run `Node.connect(:"THE_OTHER_NODE_NAME")`. Keep in mind that the names are atoms.
6. In either terminal, run `Node.list()` to check that there is a connection.
1. Run `bin/console_pubsub foo` in one terminal.
2. Run `bin/console_pubsub bar` in another terminal.
3. In either terminal, grab the current name with `Node.self()`. (The name will also be shown in the `iex` prompts).
4. In the other terminal, run `Node.connect(:"THE_OTHER_NODE_NAME")`. Keep in mind that the names are atoms.
5. In either terminal, run `Node.list()` to check that there is a connection.

Done that, modifying any flag data in either terminal will notify the other one via PubSub.
2 changes: 1 addition & 1 deletion bin/console_ecto
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ rdbms=${1:-postgres}

rm -rf _build/dev/lib/fun_with_flags/ &&
rm -rf _build/test/lib/fun_with_flags/ &&
PERSISTENCE=ecto RDBMS="$rdbms" PUBSUB_BROKER=phoenix_pubsub iex $@ -S mix;
PERSISTENCE=ecto RDBMS="$rdbms" PUBSUB_BROKER=phoenix_pubsub iex -S mix;
9 changes: 9 additions & 0 deletions bin/console_pubsub
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

nodename=${1:-one}

# Support `$@` to pass extra options to `iex`.

rm -rf _build/dev/lib/fun_with_flags/ &&
rm -rf _build/test/lib/fun_with_flags/ &&
PERSISTENCE=ecto RDBMS="postgres" PUBSUB_BROKER=phoenix_pubsub iex --name "$nodename" -S mix;

0 comments on commit 490a6be

Please sign in to comment.