[erlang-questions] API design and pgapp

Nathaniel Waisbrot <>
Tue Sep 5 19:03:16 CEST 2017


> This came up, lately: https://github.com/epgsql/pgapp/issues/22
> 
> Which seems to pit two things against one another:
> 
> * On one hand, using the process registry to keep track of the Conn
> (connection) is not very Erlang-y and might introduce errors.
> 
> * That said, it's also nice for things to be composable in the sense
> that you can write, say, update_stats() either within the transaction
> or outside and have it 'just work' without having to provide both an
> update_stats() and update_stats(Conn).



I don't think it's a productive addition to that epgsql conversation, but I would write only update_stats/1. A Postgres connection is not a trivial thing like an Erlang process.  On a default installation you only get a couple hundred of them and you can see some unpleasant surprises if you go over. Therefore, I think it's a mistake to not explicitly track your connections in the code.


More information about the erlang-questions mailing list