-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Change IOptions to IOptionsMonitor for postgresDapper. Adding connection string builder for pg dapper * Remove connection string when try to create connection string builder * Adding listenig event about changing IOptionsMonitor * Adding validation for duplicate key on library * Open _dataBaseOptions for set value and don't change link * Remove comments * Change type of port from string to int * Change field name and adding variable to save link * Adding keep alive setting for building connection string * Adding connection idle lifetime for pg connection string * Clear connection pool when need to rotate connection * Remove idle connection timeout for build connection string * Return log factory * Adding checking that UserName or Password was change before reset connection pull * Adding extensions to builder for configurate logger * Remove unuse varible. Change condition for validate credentials * Change dictionary to concurrentDictionary * remove logging * refactoring --------- Co-authored-by: Батура Иван <batura.i@MacBook-Pro-Komov.local> Co-authored-by: Станислав Терещенков <tereschenkov.s@ati.su>
- Loading branch information
1 parent
e341d8b
commit cf83124
Showing
7 changed files
with
143 additions
and
26 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
ATI.Services.Common/Logging/ConfigureLogBuildExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using ATI.Services.Common.Logging.Configuration; | ||
using Microsoft.Extensions.Configuration; | ||
|
||
namespace ATI.Services.Common.Logging; | ||
|
||
public static class ConfigureLogBuildExtensions | ||
{ | ||
public static IConfigurationBuilder AddLogger(this IConfigurationBuilder builder) | ||
{ | ||
var configurationRoot = builder.Build(); | ||
var nLogOptions = configurationRoot.GetSection("NLogOptions").Get<NLogOptions>(); | ||
var nLogConfigurator = new NLogConfigurator(nLogOptions); | ||
nLogConfigurator.ConfigureNLog(); | ||
|
||
return builder; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using Npgsql; | ||
|
||
namespace ATI.Services.Common.Sql; | ||
|
||
public static class ConnectionStringBuilder | ||
{ | ||
public static string BuildPostgresConnectionString(DataBaseOptions options) | ||
{ | ||
var builder = new NpgsqlConnectionStringBuilder(); | ||
|
||
if (options.ConnectionString != null) | ||
{ | ||
builder.ConnectionString = options.ConnectionString; | ||
return builder.ToString(); | ||
} | ||
|
||
if (options.Port != null) | ||
{ | ||
builder.Port = options.Port.Value; | ||
} | ||
|
||
if (options.Server != null) | ||
{ | ||
builder.Host = options.Server; | ||
} | ||
if (options.Database != null) | ||
{ | ||
builder.Database = options.Database; | ||
} | ||
if (options.UserName != null) | ||
{ | ||
builder.Username = options.UserName; | ||
} | ||
if (options.Password != null) | ||
{ | ||
builder.Password = options.Password; | ||
} | ||
if (options.MinPoolSize != null) | ||
{ | ||
builder.MinPoolSize = options.MinPoolSize.Value; | ||
} | ||
if (options.MaxPoolSize != null) | ||
{ | ||
builder.MaxPoolSize = options.MaxPoolSize.Value; | ||
} | ||
if (options.ConnectTimeout != null) | ||
{ | ||
builder.ConnectionLifetime = options.ConnectTimeout.Value; | ||
} | ||
if (options.KeepAlive != null) | ||
{ | ||
builder.KeepAlive = options.KeepAlive.Value; | ||
} | ||
|
||
builder.TrustServerCertificate = options.TrustServerCertificate ?? true; | ||
return builder.ToString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters