mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.5 KiB
40 lines
1.5 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Squidex.Infrastructure;
|
|
using Squidex.Infrastructure.Log;
|
|
using StackExchange.Redis;
|
|
|
|
namespace Squidex.Config.Domain
|
|
{
|
|
public static class PubSubServices
|
|
{
|
|
public static void AddMyPubSubServices(this IServiceCollection services, IConfiguration config)
|
|
{
|
|
config.ConfigureByOption("pubSub:type", new Options
|
|
{
|
|
["InMemory"] = () =>
|
|
{
|
|
services.AddSingletonAs<InMemoryPubSub>()
|
|
.As<IPubSub>();
|
|
},
|
|
["Redis"] = () =>
|
|
{
|
|
var configuration = config.GetRequiredValue("pubsub:redis:configuration");
|
|
|
|
var redis = Singletons<IConnectionMultiplexer>.GetOrAddLazy(configuration, s => ConnectionMultiplexer.Connect(s));
|
|
|
|
services.AddSingletonAs(c => new RedisPubSub(redis, c.GetRequiredService<ISemanticLog>()))
|
|
.As<IPubSub>()
|
|
.As<IInitializable>();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|