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 am trying to provide wrappers for common libraries to make it easier to send instrumentation information about the library's use to a 3rd party platform. The struct types in both sql and sqlx make this difficult, but I was happy to see that pop has a store interface. Implementing this interface as a wrapper around sqlx that emits information about the database calls looks like it can work very well. I have a proof of concept wrapper and an example that uses it to demonstrate what I mean.
The challenge comes partly with NamedStmt (though its use in pop seems limited, if I'm reading it right) and mostly with the Transaction calls. Because the store interface's Transaction function returns a *Tx type and the *Tx type embeds sqlx.Tx, it is impossible to get information about a transaction except for its initial creation. Any following statements that happen directly on the Tx type (including commits and rollbacks) are impossible to capture as a wrapper.
If the pop.Tx type were an interface instead of a struct type, I could implement a wrapper that passes through all future sql statements that happen during the transaction.
While the full surface of a sqlx.Tx is rather large (25 functions), the number of functions in the pop.Tx interface could be significantly smaller, in the same way that the store interface is significantly smaller than the full sqlx surface.
The text was updated successfully, but these errors were encountered:
I am trying to provide wrappers for common libraries to make it easier to send instrumentation information about the library's use to a 3rd party platform. The struct types in both sql and sqlx make this difficult, but I was happy to see that pop has a
store
interface. Implementing this interface as a wrapper around sqlx that emits information about the database calls looks like it can work very well. I have a proof of concept wrapper and an example that uses it to demonstrate what I mean.The challenge comes partly with NamedStmt (though its use in pop seems limited, if I'm reading it right) and mostly with the Transaction calls. Because the
store
interface'sTransaction
function returns a*Tx
type and the*Tx
type embedssqlx.Tx
, it is impossible to get information about a transaction except for its initial creation. Any following statements that happen directly on theTx
type (including commits and rollbacks) are impossible to capture as a wrapper.If the
pop.Tx
type were an interface instead of a struct type, I could implement a wrapper that passes through all future sql statements that happen during the transaction.While the full surface of a
sqlx.Tx
is rather large (25 functions), the number of functions in thepop.Tx
interface could be significantly smaller, in the same way that thestore
interface is significantly smaller than the fullsqlx
surface.The text was updated successfully, but these errors were encountered: