Skip to content

Commit 29aee6a

Browse files
committed
Option to not logout when disposing
1 parent ec6d11d commit 29aee6a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/CouchDB.Driver/CouchClient.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,10 @@ public void Dispose()
303303

304304
protected virtual void Dispose(bool disposing)
305305
{
306-
AsyncContext.Run(() => LogoutAsync().ConfigureAwait(false));
306+
if (_settings.LogOutOnDispose)
307+
{
308+
AsyncContext.Run(() => LogoutAsync().ConfigureAwait(false));
309+
}
307310
_flurlClient.Dispose();
308311
}
309312

src/CouchDB.Driver/Settings/CouchSettings.cs

+8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class CouchSettings
2323
internal DocumentCaseType DocumentsCaseType { get; private set; }
2424
internal PropertyCaseType PropertiesCase { get; private set; }
2525
internal bool CheckDatabaseExists { get; private set; }
26+
internal bool LogOutOnDispose { get; private set; }
2627
internal Func<HttpRequestMessage, X509Certificate2, X509Chain, SslPolicyErrors, bool> ServerCertificateCustomValidationCallback { get; private set; }
2728

2829
internal CouchSettings()
@@ -31,6 +32,7 @@ internal CouchSettings()
3132
PluralizeEntitis = true;
3233
DocumentsCaseType = DocumentCaseType.UnderscoreCase;
3334
PropertiesCase = PropertyCaseType.CamelCase;
35+
LogOutOnDispose = true;
3436
}
3537

3638
/// <summary>
@@ -144,5 +146,11 @@ public CouchSettings EnsureDatabaseExists()
144146
CheckDatabaseExists = true;
145147
return this;
146148
}
149+
150+
public CouchSettings DisableLogOutOnDispose()
151+
{
152+
LogOutOnDispose = false;
153+
return this;
154+
}
147155
}
148156
}

0 commit comments

Comments
 (0)