mirror of https://github.com/Squidex/squidex.git
5 changed files with 43 additions and 114 deletions
@ -1,45 +0,0 @@ |
|||||
// ==========================================================================
|
|
||||
// OrleansModule.cs
|
|
||||
// Squidex Headless CMS
|
|
||||
// ==========================================================================
|
|
||||
// Copyright (c) Squidex Group
|
|
||||
// All rights reserved.
|
|
||||
// ==========================================================================
|
|
||||
|
|
||||
using System; |
|
||||
using Autofac; |
|
||||
using Microsoft.Extensions.Configuration; |
|
||||
using Squidex.Config.Domain; |
|
||||
using Squidex.Infrastructure; |
|
||||
|
|
||||
namespace Squidex.Config.Orleans |
|
||||
{ |
|
||||
public sealed class OrleansModule : Module |
|
||||
{ |
|
||||
private IConfiguration Configuration { get; } |
|
||||
|
|
||||
public OrleansModule(IConfiguration configuration) |
|
||||
{ |
|
||||
Configuration = configuration; |
|
||||
} |
|
||||
|
|
||||
protected override void Load(ContainerBuilder builder) |
|
||||
{ |
|
||||
var storeType = Configuration.GetValue<string>("orleans:type"); |
|
||||
|
|
||||
if (string.IsNullOrWhiteSpace(storeType)) |
|
||||
{ |
|
||||
throw new ConfigurationException("Configure Orleans type with 'orleans:type'."); |
|
||||
} |
|
||||
|
|
||||
if (string.Equals(storeType, "MongoDB", StringComparison.OrdinalIgnoreCase)) |
|
||||
{ |
|
||||
builder.RegisterModule(new StoreMongoDbModule(Configuration)); |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
throw new ConfigurationException($"Unsupported value '{storeType}' for 'stores:type', supported: MongoDb."); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,42 +0,0 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Linq; |
|
||||
using System.Threading.Tasks; |
|
||||
using Autofac; |
|
||||
using Microsoft.Extensions.Configuration; |
|
||||
using Microsoft.Extensions.Options; |
|
||||
using Orleans.Providers.MongoDB; |
|
||||
|
|
||||
namespace Squidex.Config.Orleans |
|
||||
{ |
|
||||
public sealed class OrleansMongoDbModule : Module |
|
||||
{ |
|
||||
private IConfiguration Configuration { get; } |
|
||||
|
|
||||
public OrleansMongoDbModule(IConfiguration configuration) |
|
||||
{ |
|
||||
Configuration = configuration; |
|
||||
} |
|
||||
|
|
||||
protected override void Load(ContainerBuilder builder) |
|
||||
{ |
|
||||
var mongoConfig = Configuration.GetSection("orleans:mongoDb"); |
|
||||
|
|
||||
builder.RegisterInstance(Options.Create(mongoConfig.Get<MongoDBGatewayListProviderOptions>())) |
|
||||
.As<IOptions<MongoDBGatewayListProviderOptions>>() |
|
||||
.SingleInstance(); |
|
||||
|
|
||||
builder.RegisterInstance(Options.Create(mongoConfig.Get<MongoDBMembershipTableOptions>())) |
|
||||
.As<IOptions<MongoDBMembershipTableOptions>>() |
|
||||
.SingleInstance(); |
|
||||
|
|
||||
builder.RegisterInstance(Options.Create(mongoConfig.Get<MongoDBRemindersOptions>())) |
|
||||
.As<IOptions<MongoDBRemindersOptions>>() |
|
||||
.SingleInstance(); |
|
||||
|
|
||||
builder.RegisterInstance(Options.Create(mongoConfig.Get<MongoDBStatisticsOptions>())) |
|
||||
.As<IOptions<MongoDBStatisticsOptions>>() |
|
||||
.SingleInstance(); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,27 +0,0 @@ |
|||||
// ==========================================================================
|
|
||||
// OrleansSilo.cs
|
|
||||
// Squidex Headless CMS
|
|
||||
// ==========================================================================
|
|
||||
// Copyright (c) Squidex Group
|
|
||||
// All rights reserved.
|
|
||||
// ==========================================================================
|
|
||||
|
|
||||
using Orleans.Hosting; |
|
||||
using System; |
|
||||
using System.Threading.Tasks; |
|
||||
|
|
||||
namespace Squidex.Config.Orleans |
|
||||
{ |
|
||||
public sealed class OrleansSilo |
|
||||
{ |
|
||||
private readonly IServiceProvider serviceProvider; |
|
||||
|
|
||||
public Task RunAsync() |
|
||||
{ |
|
||||
new SiloHostBuilder() |
|
||||
.ConfigureLocalHostPrimarySilo(33333) |
|
||||
.ConfigureSiloName("Squidex") |
|
||||
.UseServiceProviderFactory() |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,41 @@ |
|||||
|
// ==========================================================================
|
||||
|
// SiloServices.cs
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex Group
|
||||
|
// All rights reserved.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using System.Collections.Generic; |
||||
|
using Microsoft.AspNetCore.Hosting; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Orleans; |
||||
|
using Orleans.Hosting; |
||||
|
using Orleans.Runtime.Configuration; |
||||
|
|
||||
|
namespace Squidex.Config.Orleans |
||||
|
{ |
||||
|
public static class SiloServices |
||||
|
{ |
||||
|
public static IServiceCollection AddOrleans(this IServiceCollection services, IConfiguration configuration, IHostingEnvironment hostingEnvironment) |
||||
|
{ |
||||
|
var properties = new Dictionary<object, object>(); |
||||
|
|
||||
|
var hostBuilderContext = new HostBuilderContext(new Dictionary<object, object>()) |
||||
|
{ |
||||
|
Configuration = configuration |
||||
|
}; |
||||
|
|
||||
|
var orleansConfig = configuration.GetSection("orleans"); |
||||
|
|
||||
|
var clusterConfiguration = ClusterConfiguration.LocalhostPrimarySilo(33333); |
||||
|
clusterConfiguration.AddMongoDBStatisticsProvider("Default", orleansConfig); |
||||
|
clusterConfiguration.AddMongoDBStorageProvider("Default", orleansConfig); |
||||
|
|
||||
|
services.AddD |
||||
|
|
||||
|
return services; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue