Skip to content

Commit b3551f8

Browse files
author
Maksim Golev
committed
Trying then understand integration with Apache Ignite which is unsuccessful.
1 parent d30ffe5 commit b3551f8

File tree

5 files changed

+55
-3
lines changed

5 files changed

+55
-3
lines changed

HTC/Redis/src/RedisForDummies/RedisForDummies.Api/Extensions/ServiceCollectionExtensions.cs

+26-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using Microsoft.Extensions.Caching.StackExchangeRedis;
1+
using Apache.Extensions.Caching.Ignite;
2+
using Apache.Ignite;
3+
using Microsoft.Extensions.Caching.StackExchangeRedis;
24
using RedisForDummies.Api.Settings;
35
using RedisForDummies.Application.Providers.Counters;
46
using RedisForDummies.Infrastructure.Providers.Counters;
@@ -19,7 +21,8 @@ public static IServiceCollection AddServices(this IServiceCollection services, I
1921
{
2022
services
2123
.AddApplicationServices()
22-
.AddRedis(configuration);
24+
.AddApacheIgnite(configuration)
25+
/*.AddRedis(configuration)*/;
2326

2427
return services;
2528
}
@@ -35,6 +38,27 @@ private static IServiceCollection AddApplicationServices(this IServiceCollection
3538
return services;
3639
}
3740

41+
/// <summary>
42+
/// Добавить Apache Ignite.
43+
/// </summary>
44+
/// <param name="services">Коллекция сервисов.</param>
45+
/// <param name="configuration">Конфигурация <see cref="IConfiguration"/>.</param>
46+
private static IServiceCollection AddApacheIgnite(this IServiceCollection services, IConfiguration configuration)
47+
{
48+
ApacheIgniteSettings apacheIgniteSettings;
49+
50+
apacheIgniteSettings = configuration.GetRequiredSection(nameof(ApacheIgniteSettings))
51+
.Get<ApacheIgniteSettings>()!;
52+
53+
services.AddIgniteClientGroup(new IgniteClientGroupConfiguration
54+
{
55+
ClientConfiguration = new IgniteClientConfiguration(apacheIgniteSettings.Endpoints)
56+
})
57+
.AddIgniteDistributedCache(options => options.CacheKeyPrefix = "prefix");
58+
59+
return services;
60+
}
61+
3862
/// <summary>
3963
/// Добавить Redis.
4064
/// </summary>

HTC/Redis/src/RedisForDummies/RedisForDummies.Api/RedisForDummies.Api.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13+
<PackageReference Include="Apache.Extensions.Caching.Ignite" Version="3.0.0" />
1314
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.2" />
1415
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.2" />
1516
<PackageReference Include="Swashbuckle.AspNetCore" Version="8.0.0" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace RedisForDummies.Api.Settings
2+
{
3+
/// <summary>
4+
/// Настройки для работы с Apache Ignite.
5+
/// </summary>
6+
public class ApacheIgniteSettings
7+
{
8+
/// <summary>
9+
/// Точки подключения к Apache Ignite.
10+
/// </summary>
11+
public string[] Endpoints { get; set; } = Enumerable.Empty<string>()
12+
.ToArray();
13+
}
14+
}

HTC/Redis/src/RedisForDummies/RedisForDummies.Api/appsettings.json

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
}
77
},
88
"AllowedHosts": "*",
9+
"ApacheIgniteSettings": {
10+
"Endpoints": [
11+
"ignite_instance:47100"
12+
]
13+
},
914
"RedisSettings": {
1015
//По-умолчанию контейнер Redis'а запускается на порту 6379.
1116
"Configuration": "redis_instance:6379",

HTC/Redis/src/RedisForDummies/docker-compose.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
version: '3.4'
22

33
services:
4+
ignite_instance:
5+
image: apacheignite/ignite
6+
ports:
7+
- "10800:10800"
8+
- "47100:47100"
9+
- "47101:47101"
10+
411
redis_instance:
512
image: redis
613

@@ -10,4 +17,5 @@ services:
1017
context: .
1118
dockerfile: RedisForDummies.Api/Dockerfile
1219
depends_on:
13-
- redis_instance
20+
- ignite_instance
21+
- redis_instance

0 commit comments

Comments
 (0)