Skip to content

Change Redis Insights to use new preconfigure database connections feature #8506

@eerhardt

Description

@eerhardt

See https://redis.io/docs/latest/operate/redisinsight/configuration/#:~:text=true-,Preconfigure%20database%20connections,-Redis%20Insight%20allows for this new feature.

Today we issue HTTP requests to the redis insights to configure the connection.

builder.ApplicationBuilder.Eventing.Subscribe<ResourceReadyEvent>(resource, async (e, ct) =>
{
var redisInstances = builder.ApplicationBuilder.Resources.OfType<RedisResource>();
if (!redisInstances.Any())
{
// No-op if there are no Redis resources present.
return;
}
// Wait for all endpoints to be allocated before attempting to import databases
await endpointsAllocatedTcs.Task.ConfigureAwait(false);
var redisInsightResource = builder.ApplicationBuilder.Resources.OfType<RedisInsightResource>().Single();
var insightEndpoint = redisInsightResource.PrimaryEndpoint;
using var client = new HttpClient();
client.BaseAddress = new Uri($"{insightEndpoint.Scheme}://{insightEndpoint.Host}:{insightEndpoint.Port}");
var rls = e.Services.GetRequiredService<ResourceLoggerService>();
var resourceLogger = rls.GetLogger(resource);
await ImportRedisDatabases(resourceLogger, redisInstances, client, ct).ConfigureAwait(false);
});

We should change over to the new feature so we can configure this like we do all the other "management" resource containers.

cc @Alirexaa @sebastienros

Metadata

Metadata

Assignees

Labels

area-integrationsIssues pertaining to Aspire Integrations packagesredisIssues related to redis integrations

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions