hangfire-postgres / Hangfire.PostgreSql

PostgreSql Storage Provider for Hangfire
Other
358 stars 132 forks source link

NpgsqlDataSource support #355

Closed maksimnarkevichdp closed 3 months ago

maksimnarkevichdp commented 5 months ago

Good day,

Is there any plans for NpgsqDataSource support? https://www.npgsql.org/doc/release-notes/7.0.html#dbdatasource

I am eager to help if needed.

azygis commented 5 months ago

Out of the box - yes, it's kinda planned in my mind, but can't really do it quickly without quite some overhaul of how dependencies (namely Npgsql) are handled.

I think you should be able to do it yourself by using the bootstrapper overload that accepts IConnectionFactory. You can implement the factory any way you want, including supplying the connection from your data source. One way was discussed in #342.

maksimnarkevichdp commented 5 months ago

Out of the box - yes, it's kinda planned in my mind, but can't really do it quickly without quite some overhaul of how dependencies (namely Npgsql) are handled.

I think you should be able to do it yourself by using the bootstrapper overload that accepts IConnectionFactory. You can implement the factory any way you want, including supplying the connection from your data source. One way was discussed in #342.

Thanks for the quick answer!

Can't find any info regarding what is the lifetime of IConnecitonFactory dependency?

azygis commented 5 months ago

It's not really a dependency per se, it is not resolved from the dependency container. By default it just uses a NpgsqlConnectionFactory instance which is instantiated manually internally.

You should treat it as a singleton (similar to how DbDataSource typically should be).