This is an automated email from the ASF dual-hosted git repository. ptupitsyn pushed a commit to branch ignite-27176 in repository https://gitbox.apache.org/repos/asf/ignite-3.git
commit 947557049a2c377158ae3ca25b145be146913be6 Author: Pavel Tupitsyn <[email protected]> AuthorDate: Wed Nov 26 08:29:20 2025 +0200 IGNITE-27176 .NET: Document IgniteServiceCollectionExtensions https://issues.apache.org/jira/browse/IGNITE-27176 --- docs/_docs/developers-guide/clients/dotnet.adoc | 25 +++++++++++++++------- .../IgniteServiceCollectionExtensionsTests.cs | 10 +++++++++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/docs/_docs/developers-guide/clients/dotnet.adoc b/docs/_docs/developers-guide/clients/dotnet.adoc index d20b2072246..eb6a8a13861 100644 --- a/docs/_docs/developers-guide/clients/dotnet.adoc +++ b/docs/_docs/developers-guide/clients/dotnet.adoc @@ -101,25 +101,29 @@ public class Account == Using Dependency Injection -Ignite client provides support for using link:https://learn.microsoft.com/en-us/dotnet/core/extensions/dependency-injection[Dependency Injection] when initializing a client instance. +Ignite client provides `IServiceCollection` extensions for using link:https://learn.microsoft.com/en-us/dotnet/core/extensions/dependency-injection[Dependency Injection]. This approach can be used to simplify initializing the client in DI containers: - Register the `IgniteClientGroup` in your DI container: + -[source, cpp] +[source, csharp] ---- -builder.Services.AddSingleton<IgniteClientGroup>(_ => new IgniteClientGroup( - new IgniteClientGroupConfiguration +IServiceCollection services = builder.Services; + +services.AddIgniteClientGroup(new IgniteClientGroupConfiguration +{ + ClientConfiguration = new IgniteClientConfiguration { - Size = 3, - ClientConfiguration = new("localhost"), - })); + Endpoints = { "localhost" } + }, + Size = 2 +}); ---- + - Use an instance of the group you created in your methods: + -[source, cpp] +[source, csharp] ---- public async Task<IActionResult> Index([FromServices] IgniteClientGroup igniteGroup) { @@ -129,6 +133,11 @@ public async Task<IActionResult> Index([FromServices] IgniteClientGroup igniteGr } ---- +`IgniteClientGroup` is registered as a singleton by default and provides a pool of cached Ignite client instances: + +* Ignite clients are thread-safe and can be shared between multiple consumers. +* Client instances cache table and query metadata, which improves performance for subsequent operations. + == SQL API Ignite 3 is focused on SQL, and SQL API is the primary way to work with the data. You can read more about supported SQL statements in the link:sql-reference/ddl[SQL Reference] section. Here is how you can send SQL requests: diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/IgniteServiceCollectionExtensionsTests.cs b/modules/platforms/dotnet/Apache.Ignite.Tests/IgniteServiceCollectionExtensionsTests.cs index 56a964a0df9..93a3bb89ed6 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Tests/IgniteServiceCollectionExtensionsTests.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Tests/IgniteServiceCollectionExtensionsTests.cs @@ -209,6 +209,16 @@ public class IgniteServiceCollectionExtensionsTests private static void ValidateKeyedRegistrationScope(ServiceLifetime lifetime, Action<ServiceCollection, object> register) { var services = new ServiceCollection(); + + services.AddIgniteClientGroup(new IgniteClientGroupConfiguration + { + ClientConfiguration = new IgniteClientConfiguration + { + Endpoints = { "localhost" } + }, + Size = 2 + }); + var keys = new[] { "key1", "key2" }; foreach (var key in keys)
