forked from commanded/eventstore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include guide to running on a cluster of nodes
- Loading branch information
1 parent
0bb3f87
commit 59e39f1
Showing
5 changed files
with
85 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[{kernel, | ||
[ | ||
{sync_nodes_optional, ['[email protected]', '[email protected]']}, | ||
{sync_nodes_timeout, 30000} | ||
]} | ||
]. |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[{kernel, | ||
[ | ||
{sync_nodes_optional, ['[email protected]', '[email protected]']}, | ||
{sync_nodes_timeout, 30000} | ||
]} | ||
]. |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[{kernel, | ||
[ | ||
{sync_nodes_optional, ['[email protected]', '[email protected]']}, | ||
{sync_nodes_timeout, 30000} | ||
]} | ||
]. |
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Cluster | ||
|
||
### Starting a cluster | ||
|
||
1. Run an [Erlang Port Mapper Daemon](http://erlang.org/doc/man/epmd.html) (epmd): | ||
|
||
```console | ||
$ epmd -d | ||
``` | ||
|
||
2. Start an `iex` console per node: | ||
|
||
```console | ||
$ MIX_ENV=distributed iex --name [email protected] --erl "-config cluster/node1.sys.config" -S mix | ||
``` | ||
|
||
```console | ||
$ MIX_ENV=distributed iex --name [email protected] --erl "-config cluster/node2.sys.config" -S mix | ||
``` | ||
|
||
```console | ||
$ MIX_ENV=distributed iex --name [email protected] --erl "-config cluster/node3.sys.config" -S mix | ||
``` | ||
|
||
The node specific `<node>.sys.config` files ensure the cluster is formed before starting the `:eventstore` application, assuming this occurs within the 30 seconds timeout. Once running, you can use the Event Store API from any node. Stream processes will be distributed amongst the cluster and moved around on node up/down. | ||
|
||
### Append events to a stream | ||
|
||
```elixir | ||
stream_uuid = UUID.uuid4() | ||
events = EventStore.EventFactory.create_events(3) | ||
|
||
:ok = EventStore.append_to_stream(stream_uuid, 0, events) | ||
``` | ||
|
||
### Read all events | ||
|
||
```elixir | ||
recorded_events = EventStore.stream_all_forward() |> Enum.to_list() | ||
``` | ||
|
||
### Subscribe to all Streams | ||
|
||
```elixir | ||
{:ok, subscription} = EventStore.subscribe_to_all_streams("example-subscription", self(), start_from: :origin) | ||
|
||
receive do | ||
{:events, events} -> | ||
IO.puts "Received events: #{inspect events}" | ||
EventStore.ack(subscription, events) | ||
|
||
reply -> | ||
IO.puts reply | ||
end | ||
``` | ||
|
||
## Cluster diagnostics | ||
|
||
Peek into the Swarm process registry: | ||
|
||
```elixir | ||
Swarm.Registry.registered() | ||
``` |
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