cpursley / walex

Postgres change events (CDC) in Elixir
MIT License
286 stars 15 forks source link

Provided setup example has a minor bug #10

Closed oortlieb closed 2 years ago

oortlieb commented 2 years ago

Copy/pasting the example from the README yielded the following error:

** (Mix) Could not start application XXX: XXX.Application.start(:normal, []) returned an error: shutdown: failed to start child: WalEx.Supervisor
    ** (EXIT) an exception was raised:
        ** (Jason.DecodeError) unexpected byte at position 0: 0x65 ("e")
            (jason 1.3.0) lib/jason.ex:92: Jason.decode!/2
            (walex 0.7.4) lib/walex/supervisor.ex:40: WalEx.Supervisor.init/1
            (stdlib 3.16) supervisor.erl:330: :supervisor.init/1
            (stdlib 3.16) gen_server.erl:423: :gen_server.init_it/2
            (stdlib 3.16) gen_server.erl:390: :gen_server.init_it/6
            (stdlib 3.16) proc_lib.erl:226: :proc_lib.init_p_do_apply/3

The relevant part of my :walex config:

config :walex,
  db_host: "localhost",
  db_user: "postgres",
  db_name: "postgres",
  // omitting some stuff
  max_replication_lag_in_mb: 0,
  publications: ["example"], // this line causes the error
  // more unrelated stuff

Digging into it a bit, it looks like the :publications key is being JSON decoded. The README could be updated to indicate that value should be a JSON-decodable string, or the Jason.decode() could be removed from lib/walex/supervisor.ex:40. In my case, updating the :publications value to publications: "[\"example\"]" avoids the error.

cpursley commented 2 years ago

Thanks for pointing that out, fixed!