VOOZH about

URL: https://www.nuget.org/packages/AnyoneDeveloper.ClickHouse.ConnectionPool/

⇱ NuGet Gallery | AnyoneDeveloper.ClickHouse.ConnectionPool 1.0.1




AnyoneDeveloper.ClickHouse.ConnectionPool 1.0.1

dotnet add package AnyoneDeveloper.ClickHouse.ConnectionPool --version 1.0.1
 
 
NuGet\Install-Package AnyoneDeveloper.ClickHouse.ConnectionPool -Version 1.0.1
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AnyoneDeveloper.ClickHouse.ConnectionPool" Version="1.0.1" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AnyoneDeveloper.ClickHouse.ConnectionPool" Version="1.0.1" />
 
Directory.Packages.props
<PackageReference Include="AnyoneDeveloper.ClickHouse.ConnectionPool" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AnyoneDeveloper.ClickHouse.ConnectionPool --version 1.0.1
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AnyoneDeveloper.ClickHouse.ConnectionPool, 1.0.1"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AnyoneDeveloper.ClickHouse.ConnectionPool@1.0.1
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AnyoneDeveloper.ClickHouse.ConnectionPool&version=1.0.1
 
Install as a Cake Addin
#tool nuget:?package=AnyoneDeveloper.ClickHouse.ConnectionPool&version=1.0.1
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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 net5.0 is compatible.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 was computed.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 633 5/20/2021
1.0.0 1,448 5/19/2021 1.0.0 is deprecated.