AnyoneDeveloper.ClickHouse.ConnectionPool
1.0.0
AnyoneDeveloper.ClickHouse.ConnectionPool 1.0.1
Additional DetailsSometimes the connection will unexpectly close connection from remoting server.
See the version list below for details.
dotnet add package AnyoneDeveloper.ClickHouse.ConnectionPool --version 1.0.0
NuGet\Install-Package AnyoneDeveloper.ClickHouse.ConnectionPool -Version 1.0.0
<PackageReference Include="AnyoneDeveloper.ClickHouse.ConnectionPool" Version="1.0.0" />
paket add AnyoneDeveloper.ClickHouse.ConnectionPool --version 1.0.0
#r "nuget: AnyoneDeveloper.ClickHouse.ConnectionPool, 1.0.0"
// Install AnyoneDeveloper.ClickHouse.ConnectionPool as a Cake Addin #addin nuget:?package=AnyoneDeveloper.ClickHouse.ConnectionPool&version=1.0.0 // Install AnyoneDeveloper.ClickHouse.ConnectionPool as a Cake Tool #tool nuget:?package=AnyoneDeveloper.ClickHouse.ConnectionPool&version=1.0.0
anyone-dotnet-use-clickhouse-connection-pool
This nuget package help you to use Octonica.ClickHouseClient with connection pool. You can fully control the concurrent query with "select" I/O mode. The original client repo is here: https://github.com/Octonica/ClickHouseClient
This repo would bundle nuget package. Anyone can reference it from nuget.org.
nuget package: https://www.nuget.org/packages/AnyoneDeveloper.ClickHouse.ConnectionPool/
If you like my module, please buy me a coffee.
More and more tiny and useful GitHub action modules are on the way. Please donate to me. I accept a part-time job contract. if you need, please contact me: zhang_nan_163@163.com
How to use
Inject referenced class
- Add AnyoneDeveloper.ClickHouse.ConnectionPool package reference.
- Inject Repository and Connection class
- Inject Repository class
services.AddScoped<IClickHouseRepository, ClickHouseRepository>();
- Inject Connection class
services.AddSingleton(x => new ClickHouseConnection(_configuration.GetValue<int>("Connection:Count"), _configuration.GetValue<string>("ConnectionStrings:SRV")) .InitSemaphore(_configuration.GetValue<int>("Connection:InitialConcurrentCount"), _configuration.GetValue<int>("Connection:MaximumConcurrentCount")));
Set up configuration
- Set up connection pool size It should greater than concurrent size.
- Set up SemaphoreSlim InitCount and MaxCount
Define execution method
private static async Task<IEnumerable<Foo>> GetSomeDataAsync(ClickHouseConnection conn, string sql)
{
using var cmd = conn.CreateCommand(sql);
var items = new List<Foo>();
using (var reader = await cmd.ExecuteReaderAsync())
{
while (await reader.ReadAsync())
{
var item = new Foo();
item.ID = await reader.GetFieldValueAsync<int>(0);
item.Name = await reader.GetFieldValueAsync<string>(1);
item.Job = await reader.GetFieldValueAsync<string>(2);
items.Add(item);
}
}
return items;
}
Use it as below code:
var sql = @"SELECT ID, Name, Job FROM one_table";
var data = repository.GetResultAsync((conn) => GetSomeDataAsync(conn, sql));
You can reference complete code from Demo
Donation
PalPal: https://paypal.me/nzhang4
<img src="https://raw.githubusercontent.com/anyone-developer/anyone-dotnet-use-grpc-ui/main/misc/alipay.JPG" width="500">
<img src="https://raw.githubusercontent.com/anyone-developer/anyone-dotnet-use-grpc-ui/main/misc/webchat_pay.JPG" width="500">
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net5.0
- Microsoft.Extensions.Configuration.Abstractions (>= 5.0.0)
- Octonica.ClickHouseClient (>= 1.1.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.