Skip to content

Commit e78a56a

Browse files
committed
add metadata field to help people configure genserver
1 parent e29ca40 commit e78a56a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

README.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ It also offers a decoder in PostgresReplication.Decoder based on [https://github
88
Provide the options to connect to the database and the message handler module. As an example present in the [examples](./example/) folder here's how you can track events on all tables:
99

1010
```elixir
11+
Mix.install([{:postgres_replication, git: "https://github.com/filipecabaco/postgres_replication.git"}])
1112
defmodule Handler do
1213
@behaviour PostgresReplication.Handler
1314
import PostgresReplication.Protocol
@@ -27,7 +28,8 @@ defmodule Handler do
2728
reply =
2829
case parse(message) do
2930
%KeepAlive{reply: :now, wal_end: wal_end} ->
30-
standby(wal_end + 1, wal_end + 1, wal_end + 1, :now)
31+
wal_end = wal_end + 1
32+
standby(wal_end, wal_end, wal_end, :now)
3133

3234
_ ->
3335
hold()
@@ -46,22 +48,18 @@ options = %PostgresReplication{
4648
username: "postgres",
4749
password: "postgres",
4850
database: "postgres",
49-
port: 5432,
50-
parameters: [
51-
application_name: "PostgresReplication"
52-
]
5351
],
5452
table: :all,
5553
opts: [name: __MODULE__, auto_reconnect: true],
5654
handler_module: Handler,
57-
parent_pid: self()
5855
}
5956

6057
PostgresReplication.start_link(options)
6158
```
6259

6360
## Installation
6461

62+
6563
```elixir
6664
def deps do
6765
[

lib/postgres_replication.ex

+4-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ defmodule PostgresReplication do
4040
replication_slot_name: String.t(),
4141
output_plugin: String.t(),
4242
proto_version: integer(),
43-
handler_module: Handler.t()
43+
handler_module: Handler.t(),
44+
metadata: map()
4445
}
4546
defstruct connection_opts: nil,
4647
table: nil,
@@ -51,7 +52,8 @@ defmodule PostgresReplication do
5152
replication_slot_name: nil,
5253
output_plugin: "pgoutput",
5354
proto_version: 1,
54-
handler_module: nil
55+
handler_module: nil,
56+
metadata: %{}
5557

5658
def start_link(%__MODULE__{opts: opts, connection_opts: connection_opts} = attrs) do
5759
Postgrex.ReplicationConnection.start_link(

0 commit comments

Comments
 (0)