You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I implemented data change notifications for the SQLite driver. Given a connection and a pid, whenever an insert/update/delete on the connection is performed, the SQLite NIF will send a message to the pid.
This works well on the driver level but on the Ecto level it's not so straight forward for a couple reasons:
We are accessing a pool and not creating the connections ourselves directly
The SQLite driver stores the handle for the database in the connection's state.
Why # 2 is relevant is because I thought about using :after_connect to hook the connections to the listener. But the only argument passed to it is %DBConnection{}, which doesn't have the database handle. Without access to the state it's not possible to use the SQLite connection.
Proposal/question
Would it make sense to allow users to supply a 2-arity function which receives the connection and the state? If the answer is yes, we also allow {m, f, a} so should that one be deprecated to avoid confusion (i.e. why is state not passed to mfa)?
The text was updated successfully, but these errors were encountered:
I would like to hold on this one for now because I think that SQLite should not be using db_connection. We have on going discussions about this on their issues tracker. :)
Background
I implemented data change notifications for the SQLite driver. Given a connection and a pid, whenever an insert/update/delete on the connection is performed, the SQLite NIF will send a message to the pid.
This works well on the driver level but on the Ecto level it's not so straight forward for a couple reasons:
Why # 2 is relevant is because I thought about using
:after_connect
to hook the connections to the listener. But the only argument passed to it is%DBConnection{}
, which doesn't have the database handle. Without access to the state it's not possible to use the SQLite connection.Proposal/question
Would it make sense to allow users to supply a 2-arity function which receives the connection and the state? If the answer is yes, we also allow
{m, f, a}
so should that one be deprecated to avoid confusion (i.e. why is state not passed to mfa)?The text was updated successfully, but these errors were encountered: