A wrapper around NpgsqlConnection that handles retries and reconnects.
Works with Postgresql and CockroachDB.
Using ResilientConnection
as your main connection enables the best recovery.
var connStr = @"Server=127.0.0.1;Port=26299;Database=testdb;User Id=root;...";
using var conn = new ResilientConnection(connStr);
var result = conn.Query<string>("SELECT ...")...
This will reduce the scope of errors that can be recovered
var connStr = @"Server=127.0.0.1;Port=26299;Database=testdb;User Id=root;...";
var baseConnection = new NpgsqlConnection(connStr);
using var conn = new ResilientConnection(baseConnection);
...
By default, ResilientConnection
logs messages to the console.
This can be changed with the static ResilientConnection.Log
:
ResilientConnection.Log = new MyLogHook();