mirror of https://github.com/Squidex/squidex.git
17 changed files with 291 additions and 310 deletions
@ -0,0 +1,64 @@ |
|||||
|
// ==========================================================================
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
||||
|
// All rights reserved. Licensed under the MIT license.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using System; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Newtonsoft.Json; |
||||
|
using Squidex.Infrastructure; |
||||
|
using Squidex.Infrastructure.Log; |
||||
|
using Squidex.Pipeline; |
||||
|
|
||||
|
#pragma warning disable RECS0092 // Convert field to readonly
|
||||
|
|
||||
|
namespace Squidex.Config.Domain |
||||
|
{ |
||||
|
public static class LoggingServices |
||||
|
{ |
||||
|
private static ILogChannel console = new ConsoleLogChannel(); |
||||
|
private static ILogChannel file; |
||||
|
|
||||
|
public static void AddMyLoggingServices(this IServiceCollection services, IConfiguration config) |
||||
|
{ |
||||
|
if (config.GetValue<bool>("logging:human")) |
||||
|
{ |
||||
|
services.AddSingletonAs(c => new Func<IObjectWriter>(() => new JsonLogWriter(Formatting.Indented, true))); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
services.AddSingletonAs(c => new Func<IObjectWriter>(() => new JsonLogWriter())); |
||||
|
} |
||||
|
|
||||
|
var loggingFile = config.GetValue<string>("logging:file"); |
||||
|
|
||||
|
if (!string.IsNullOrWhiteSpace(loggingFile)) |
||||
|
{ |
||||
|
services.AddSingletonAs(file ?? (file = new FileChannel(loggingFile))) |
||||
|
.As<ILogChannel>() |
||||
|
.As<IInitializable>(); |
||||
|
} |
||||
|
|
||||
|
services.AddSingletonAs(console) |
||||
|
.As<ILogChannel>(); |
||||
|
|
||||
|
services.AddSingletonAs(c => new ApplicationInfoLogAppender(typeof(Program).Assembly, Guid.NewGuid())) |
||||
|
.As<ILogAppender>(); |
||||
|
|
||||
|
services.AddSingletonAs<ActionContextLogAppender>() |
||||
|
.As<ILogAppender>(); |
||||
|
|
||||
|
services.AddSingletonAs<TimestampLogAppender>() |
||||
|
.As<ILogAppender>(); |
||||
|
|
||||
|
services.AddSingletonAs<DebugLogChannel>() |
||||
|
.As<ILogChannel>(); |
||||
|
|
||||
|
services.AddSingletonAs<SemanticLog>() |
||||
|
.As<ISemanticLog>(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,40 +0,0 @@ |
|||||
// ==========================================================================
|
|
||||
// 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>(); |
|
||||
} |
|
||||
}); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,123 +0,0 @@ |
|||||
// ==========================================================================
|
|
||||
// Squidex Headless CMS
|
|
||||
// ==========================================================================
|
|
||||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
||||
// All rights reserved. Licensed under the MIT license.
|
|
||||
// ==========================================================================
|
|
||||
|
|
||||
using System.Linq; |
|
||||
using Microsoft.Extensions.Configuration; |
|
||||
using Microsoft.Extensions.DependencyInjection; |
|
||||
using Microsoft.Extensions.Options; |
|
||||
using Squidex.Domain.Apps.Core.HandleRules; |
|
||||
using Squidex.Domain.Apps.Core.HandleRules.Actions; |
|
||||
using Squidex.Domain.Apps.Core.HandleRules.Triggers; |
|
||||
using Squidex.Domain.Apps.Entities; |
|
||||
using Squidex.Domain.Apps.Entities.Apps; |
|
||||
using Squidex.Domain.Apps.Entities.Apps.Services; |
|
||||
using Squidex.Domain.Apps.Entities.Apps.Services.Implementations; |
|
||||
using Squidex.Domain.Apps.Entities.Contents; |
|
||||
using Squidex.Domain.Apps.Entities.Contents.Edm; |
|
||||
using Squidex.Domain.Apps.Entities.Contents.GraphQL; |
|
||||
using Squidex.Domain.Apps.Entities.History; |
|
||||
using Squidex.Domain.Apps.Entities.Rules; |
|
||||
using Squidex.Domain.Apps.Entities.Schemas; |
|
||||
using Squidex.Domain.Users; |
|
||||
using Squidex.Infrastructure; |
|
||||
using Squidex.Infrastructure.Assets; |
|
||||
using Squidex.Infrastructure.EventSourcing; |
|
||||
using Squidex.Infrastructure.EventSourcing.Grains; |
|
||||
using Squidex.Pipeline; |
|
||||
|
|
||||
namespace Squidex.Config.Domain |
|
||||
{ |
|
||||
public static class ReadServices |
|
||||
{ |
|
||||
public static void AddMyReadServices(this IServiceCollection services, IConfiguration config) |
|
||||
{ |
|
||||
services.AddSingletonAs<OrleansEventNotifier>() |
|
||||
.As<IEventNotifier>() |
|
||||
.As<IInitializable>(); |
|
||||
|
|
||||
var exposeSourceUrl = config.GetOptionalValue("assetStore:exposeSourceUrl", true); |
|
||||
|
|
||||
services.AddSingletonAs(c => new GraphQLUrlGenerator( |
|
||||
c.GetRequiredService<IOptions<MyUrlsOptions>>(), |
|
||||
c.GetRequiredService<IAssetStore>(), |
|
||||
exposeSourceUrl)) |
|
||||
.As<IGraphQLUrlGenerator>(); |
|
||||
|
|
||||
services.AddSingletonAs(c => c.GetService<IOptions<MyUsageOptions>>()?.Value?.Plans.OrEmpty()); |
|
||||
|
|
||||
services.AddSingletonAs<CachingGraphQLService>() |
|
||||
.As<IGraphQLService>(); |
|
||||
|
|
||||
services.AddSingletonAs<ContentQueryService>() |
|
||||
.As<IContentQueryService>(); |
|
||||
|
|
||||
services.AddSingletonAs<ConfigAppPlansProvider>() |
|
||||
.As<IAppPlansProvider>(); |
|
||||
|
|
||||
services.AddSingletonAs<AssetUserPictureStore>() |
|
||||
.As<IUserPictureStore>(); |
|
||||
|
|
||||
services.AddSingletonAs<AppHistoryEventsCreator>() |
|
||||
.As<IHistoryEventsCreator>(); |
|
||||
|
|
||||
services.AddSingletonAs<ContentHistoryEventsCreator>() |
|
||||
.As<IHistoryEventsCreator>(); |
|
||||
|
|
||||
services.AddSingletonAs<SchemaHistoryEventsCreator>() |
|
||||
.As<IHistoryEventsCreator>(); |
|
||||
|
|
||||
services.AddSingletonAs<NoopAppPlanBillingManager>() |
|
||||
.As<IAppPlanBillingManager>(); |
|
||||
|
|
||||
services.AddSingletonAs<AppProvider>() |
|
||||
.As<IAppProvider>(); |
|
||||
|
|
||||
services.AddSingletonAs<RuleEventFormatter>() |
|
||||
.AsSelf(); |
|
||||
|
|
||||
services.AddSingletonAs<AssetChangedTriggerHandler>() |
|
||||
.As<IRuleTriggerHandler>(); |
|
||||
|
|
||||
services.AddSingletonAs<ContentChangedTriggerHandler>() |
|
||||
.As<IRuleTriggerHandler>(); |
|
||||
|
|
||||
services.AddSingletonAs<AlgoliaActionHandler>() |
|
||||
.As<IRuleActionHandler>(); |
|
||||
|
|
||||
services.AddSingletonAs<AzureQueueActionHandler>() |
|
||||
.As<IRuleActionHandler>(); |
|
||||
|
|
||||
services.AddSingletonAs<ElasticSearchActionHandler>() |
|
||||
.As<IRuleActionHandler>(); |
|
||||
|
|
||||
services.AddSingletonAs<FastlyActionHandler>() |
|
||||
.As<IRuleActionHandler>(); |
|
||||
|
|
||||
services.AddSingletonAs<SlackActionHandler>() |
|
||||
.As<IRuleActionHandler>(); |
|
||||
|
|
||||
services.AddSingletonAs<WebhookActionHandler>() |
|
||||
.As<IRuleActionHandler>(); |
|
||||
|
|
||||
services.AddSingletonAs<RuleEnqueuer>() |
|
||||
.As<IEventConsumer>(); |
|
||||
|
|
||||
services.AddSingletonAs(c => |
|
||||
{ |
|
||||
var allEventConsumers = c.GetServices<IEventConsumer>(); |
|
||||
|
|
||||
return new EventConsumerFactory(n => allEventConsumers.FirstOrDefault(x => x.Name == n)); |
|
||||
}); |
|
||||
|
|
||||
services.AddSingletonAs<EdmModelBuilder>() |
|
||||
.AsSelf(); |
|
||||
|
|
||||
services.AddSingletonAs<RuleService>() |
|
||||
.AsSelf(); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,55 @@ |
|||||
|
// ==========================================================================
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
||||
|
// All rights reserved. Licensed under the MIT license.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Squidex.Domain.Apps.Core.HandleRules; |
||||
|
using Squidex.Domain.Apps.Core.HandleRules.Actions; |
||||
|
using Squidex.Domain.Apps.Core.HandleRules.Triggers; |
||||
|
using Squidex.Domain.Apps.Entities.Rules; |
||||
|
using Squidex.Infrastructure.EventSourcing; |
||||
|
|
||||
|
namespace Squidex.Config.Domain |
||||
|
{ |
||||
|
public static class RuleServices |
||||
|
{ |
||||
|
public static void AddMyRuleServices(this IServiceCollection services) |
||||
|
{ |
||||
|
services.AddSingletonAs<AssetChangedTriggerHandler>() |
||||
|
.As<IRuleTriggerHandler>(); |
||||
|
|
||||
|
services.AddSingletonAs<ContentChangedTriggerHandler>() |
||||
|
.As<IRuleTriggerHandler>(); |
||||
|
|
||||
|
services.AddSingletonAs<AlgoliaActionHandler>() |
||||
|
.As<IRuleActionHandler>(); |
||||
|
|
||||
|
services.AddSingletonAs<AzureQueueActionHandler>() |
||||
|
.As<IRuleActionHandler>(); |
||||
|
|
||||
|
services.AddSingletonAs<ElasticSearchActionHandler>() |
||||
|
.As<IRuleActionHandler>(); |
||||
|
|
||||
|
services.AddSingletonAs<FastlyActionHandler>() |
||||
|
.As<IRuleActionHandler>(); |
||||
|
|
||||
|
services.AddSingletonAs<SlackActionHandler>() |
||||
|
.As<IRuleActionHandler>(); |
||||
|
|
||||
|
services.AddSingletonAs<WebhookActionHandler>() |
||||
|
.As<IRuleActionHandler>(); |
||||
|
|
||||
|
services.AddSingletonAs<RuleEnqueuer>() |
||||
|
.As<IEventConsumer>(); |
||||
|
|
||||
|
services.AddSingletonAs<RuleEventFormatter>() |
||||
|
.AsSelf(); |
||||
|
|
||||
|
services.AddSingletonAs<RuleService>() |
||||
|
.AsSelf(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,34 @@ |
|||||
|
// ==========================================================================
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
||||
|
// All rights reserved. Licensed under the MIT license.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Options; |
||||
|
using Squidex.Domain.Apps.Entities.Apps.Services; |
||||
|
using Squidex.Domain.Apps.Entities.Apps.Services.Implementations; |
||||
|
using Squidex.Domain.Users; |
||||
|
using Squidex.Infrastructure; |
||||
|
|
||||
|
namespace Squidex.Config.Domain |
||||
|
{ |
||||
|
public static class SubscriptionServices |
||||
|
{ |
||||
|
public static void AddMySubscriptionServices(this IServiceCollection services, IConfiguration config) |
||||
|
{ |
||||
|
services.AddSingletonAs(c => c.GetService<IOptions<MyUsageOptions>>()?.Value?.Plans.OrEmpty()); |
||||
|
|
||||
|
services.AddSingletonAs<ConfigAppPlansProvider>() |
||||
|
.As<IAppPlansProvider>(); |
||||
|
|
||||
|
services.AddSingletonAs<NoopAppPlanBillingManager>() |
||||
|
.As<IAppPlanBillingManager>(); |
||||
|
|
||||
|
services.AddSingletonAs<AssetUserPictureStore>() |
||||
|
.As<IUserPictureStore>(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue