Supervising multiple postgrex children with poolboy

Hi!

Just wanted to ask if its possible to setup multiple Postgrex.child_spec(…) in the application.ex file.

Postgrex.child_spec([id: :my_worker_1, name: :test, pool: DBConnection.Poolboy]), 
Postgrex.child_spec([id: :my_worker_2, name: :test2, pool: DBConnection.Poolboy])

I tried setting it up with different ids but it seems that it still thinks its has the same id .

bad child specification, more than one child specification has the id: DBConnection.Poolboy.

I can start the workers using %{id: …, start: {}} but the process dies if there are db connection problems. So I thought I can just put them in a supervisor. I needed 2 separate ones because its connecting to 2 different dbs.

Thanks in advance! I couldn’t figure it out after reading the supervisor doc, dbconnection doc and postgrex doc and some poolboy. =P So thought I’d ask maybe its not even supported. :stuck_out_tongue:

1 Like