Compare commits
4
Commits
079048dff5
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8336e283e | ||
|
|
8d2d13ff3b | ||
|
|
06c92f5eeb | ||
|
|
28e679235c |
@@ -1,5 +1,5 @@
|
||||
using xEventService.Constants;
|
||||
using xEventService.Models;
|
||||
using xEventService.Constants;
|
||||
|
||||
namespace xEventService.Configuration
|
||||
{
|
||||
|
||||
+4
-155
@@ -1,13 +1,11 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using xCommons.Extensions;
|
||||
using xEventService.Configuration;
|
||||
using xExceptions.Constants;
|
||||
using xEventService.Constants;
|
||||
using xEventService.Extensions;
|
||||
using xEventService.Interfaces;
|
||||
using xEventService.Providers;
|
||||
using xExceptions.Constants;
|
||||
using xEventService.Configuration;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace xEventService.DI
|
||||
{
|
||||
@@ -76,104 +74,6 @@ namespace xEventService.DI
|
||||
services.AddSingleton(configuration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register Service ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="configuration"></param>
|
||||
/// <param name="lifeTime"></param>
|
||||
public static void AddXEventService(
|
||||
this IServiceCollection source,
|
||||
IConfiguration configuration,
|
||||
ServiceLifetime lifeTime = ServiceLifetime.Scoped
|
||||
)
|
||||
{
|
||||
//
|
||||
var config = configuration.GetXEventServiceConfiguration();
|
||||
source.AddEventService(
|
||||
lifeTime: lifeTime,
|
||||
configuration: config
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register Service ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="configuration"></param>
|
||||
/// <param name="lifeTime"></param>
|
||||
public static void AddXEventService(
|
||||
this IServiceCollection source,
|
||||
XEventServiceConfiguration configuration,
|
||||
ServiceLifetime lifeTime = ServiceLifetime.Scoped
|
||||
)
|
||||
{
|
||||
//
|
||||
source.AddEventService(
|
||||
lifeTime: lifeTime,
|
||||
configuration: configuration
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event Consumer Service Registration ...
|
||||
/// </summary>
|
||||
/// <typeparam name="TConsumer"></typeparam>
|
||||
/// <param name="source"></param>
|
||||
public static void AddXEventServiceConsumer<TConsumer>(
|
||||
this IServiceCollection source
|
||||
) where TConsumer : XBaseEventConsumerBackgroundService
|
||||
{
|
||||
//
|
||||
var config = source.GetRegisteredService<XEventServiceConfiguration>();
|
||||
if (config.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
Log("Consumer Registration Faild, due Invalid Configuration issue ...");
|
||||
XException.InvalidConfiguration.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
var consumerType = typeof(TConsumer);
|
||||
switch (config.Broker)
|
||||
{
|
||||
//
|
||||
case XEventBroker.XKafka:
|
||||
//
|
||||
if (!typeof(XKafkaConsumerServiceBase).IsAssignableFrom(consumerType))
|
||||
{
|
||||
//
|
||||
Log($"Consumer Registration Failed. TConsumer must inherit from XKafkaConsumerServiceBase when Broker is {config.Broker.GetStringValue()} ...");
|
||||
XException.InvalidConfiguration.Throw();
|
||||
}
|
||||
break;
|
||||
|
||||
//
|
||||
case XEventBroker.XZeroMQ:
|
||||
if (!typeof(XZeroMQConsumerServiceBase).IsAssignableFrom(consumerType))
|
||||
{
|
||||
Log($"Consumer Registration Failed. TConsumer must inherit from XZeroMQConsumerServiceBase when Broker is {config.Broker.GetStringValue()} ...");
|
||||
XException.InvalidConfiguration.Throw();
|
||||
}
|
||||
break;
|
||||
|
||||
//
|
||||
case XEventBroker.XRabbitMQ:
|
||||
if (!typeof(XRabbitMQConsumerServiceBase).IsAssignableFrom(consumerType))
|
||||
{
|
||||
Log($"Consumer Registration Failed. TConsumer must inherit from XRabbitMQConsumerServiceBase when Broker is {config.Broker.GetStringValue()} ...");
|
||||
XException.InvalidConfiguration.Throw();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
source.AddXBackgroundService<TConsumer>();
|
||||
|
||||
//
|
||||
Log($"Consumer Registered Successfully: {consumerType.Name} for Broker: {config.Broker.GetStringValue()} ...");
|
||||
}
|
||||
|
||||
//
|
||||
#region Private ...
|
||||
/// <summary>
|
||||
@@ -189,57 +89,6 @@ namespace xEventService.DI
|
||||
{
|
||||
Console.WriteLine($"{XLogTag} => {message}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register Event Service ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="configuration"></param>
|
||||
/// <param name="lifeTime"></param>
|
||||
private static void AddEventService(
|
||||
this IServiceCollection source,
|
||||
XEventServiceConfiguration configuration,
|
||||
ServiceLifetime lifeTime = ServiceLifetime.Scoped
|
||||
)
|
||||
{
|
||||
//
|
||||
// Register Configuration ...
|
||||
source.AddXEventServiceConfiguration(configuration);
|
||||
|
||||
//
|
||||
// Register based on Broker ...
|
||||
switch (configuration.Broker)
|
||||
{
|
||||
//
|
||||
case XEventBroker.XKafka:
|
||||
source.Add(
|
||||
new ServiceDescriptor(typeof(IXKafkaProducerService), typeof(XKafkaProducerService), lifeTime)
|
||||
);
|
||||
break;
|
||||
|
||||
//
|
||||
case XEventBroker.XZeroMQ:
|
||||
source.Add(
|
||||
new ServiceDescriptor(typeof(IXZeroMQProducerService), typeof(XZeroMQProducerService), lifeTime)
|
||||
);
|
||||
break;
|
||||
|
||||
//
|
||||
case XEventBroker.XRabbitMQ:
|
||||
source.Add(
|
||||
new ServiceDescriptor(typeof(IXRabbitMQProducerService), typeof(XRabbitMQProducerService), lifeTime)
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
source.Add(
|
||||
new ServiceDescriptor(typeof(IXEventServiceProvider), typeof(XEventServiceProvider), lifeTime)
|
||||
);
|
||||
|
||||
//
|
||||
Log($"Service Registered Sucessfull, Provider: {configuration.Broker.GetStringValue()}");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
using System.Linq;
|
||||
using xCommons.Extensions;
|
||||
using xEventService.Configuration;
|
||||
using xEventService.Constants;
|
||||
using xEventService.Models;
|
||||
using xExceptions.Constants;
|
||||
using xEventService.Constants;
|
||||
using xEventService.Configuration;
|
||||
|
||||
namespace xEventService.Extensions
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using xEventService.Models;
|
||||
using System.Threading.Tasks;
|
||||
using xEventService.Constants;
|
||||
using xEventService.Models;
|
||||
|
||||
namespace xEventService.Interfaces
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using xEventService.Models;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace xEventService.Interfaces
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace xEventService.Models
|
||||
{
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xCommons.Extensions;
|
||||
using xCommons.Providers;
|
||||
using xEventService.Configuration;
|
||||
using xCommons.Extensions;
|
||||
using xExceptions.Constants;
|
||||
using xEventService.Constants;
|
||||
using xEventService.Extensions;
|
||||
using xExceptions.Constants;
|
||||
using xEventService.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace xEventService.Providers
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xCommons.Extensions;
|
||||
using xEventService.Configuration;
|
||||
using xEventService.Extensions;
|
||||
using xExceptions.Constants;
|
||||
using xEventService.Extensions;
|
||||
using xEventService.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace xEventService.Providers
|
||||
{
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using xCommons.Extensions;
|
||||
using xEventService.Configuration;
|
||||
using xEventService.Models;
|
||||
using xExceptions.Constants;
|
||||
using System.Threading.Tasks;
|
||||
using xEventService.Constants;
|
||||
using xEventService.Extensions;
|
||||
using xEventService.Interfaces;
|
||||
using xEventService.Models;
|
||||
using xExceptions.Constants;
|
||||
using xEventService.Configuration;
|
||||
|
||||
namespace xEventService.Providers
|
||||
{
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Confluent.Kafka;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Threading;
|
||||
using xCommons.Extensions;
|
||||
using xEventService.Configuration;
|
||||
using xEventService.Constants;
|
||||
using xEventService.Extensions;
|
||||
using xEventService.Models;
|
||||
using xExceptions.Constants;
|
||||
using System.Threading.Tasks;
|
||||
using xEventService.Constants;
|
||||
using xEventService.Extensions;
|
||||
using xEventService.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace xEventService.Providers
|
||||
{
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
using System;
|
||||
using Confluent.Kafka;
|
||||
using System.Threading;
|
||||
using xCommons.Extensions;
|
||||
using xEventService.Models;
|
||||
using xExceptions.Constants;
|
||||
using System.Threading.Tasks;
|
||||
using xEventService.Constants;
|
||||
using xEventService.Extensions;
|
||||
using xEventService.Interfaces;
|
||||
using xEventService.Configuration;
|
||||
using xEventService.Models;
|
||||
using Confluent.Kafka;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using xEventService.Constants;
|
||||
using System;
|
||||
|
||||
namespace xEventService.Providers
|
||||
{
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using RabbitMQ.Client;
|
||||
using RabbitMQ.Client.Events;
|
||||
using System.Threading;
|
||||
using xCommons.Extensions;
|
||||
using xEventService.Configuration;
|
||||
using xEventService.Constants;
|
||||
using xEventService.Extensions;
|
||||
using xEventService.Models;
|
||||
using xExceptions.Constants;
|
||||
using System.Threading.Tasks;
|
||||
using RabbitMQ.Client.Events;
|
||||
using xEventService.Constants;
|
||||
using xEventService.Extensions;
|
||||
using xEventService.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace xEventService.Providers
|
||||
{
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using RabbitMQ.Client;
|
||||
using System.Threading;
|
||||
using xCommons.Extensions;
|
||||
using xEventService.Configuration;
|
||||
using xEventService.Models;
|
||||
using xExceptions.Constants;
|
||||
using System.Threading.Tasks;
|
||||
using xEventService.Constants;
|
||||
using xEventService.Extensions;
|
||||
using xEventService.Interfaces;
|
||||
using xEventService.Models;
|
||||
using xExceptions.Constants;
|
||||
using xEventService.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace xEventService.Providers
|
||||
{
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
using NetMQ;
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NetMQ;
|
||||
using NetMQ.Sockets;
|
||||
using System.Threading;
|
||||
using xCommons.Extensions;
|
||||
using xEventService.Configuration;
|
||||
using xEventService.Constants;
|
||||
using xEventService.Extensions;
|
||||
using xEventService.Models;
|
||||
using xExceptions.Constants;
|
||||
using System.Threading.Tasks;
|
||||
using xEventService.Constants;
|
||||
using xEventService.Extensions;
|
||||
using xEventService.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace xEventService.Providers
|
||||
{
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
using NetMQ;
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NetMQ;
|
||||
using NetMQ.Sockets;
|
||||
using System.Threading;
|
||||
using xCommons.Extensions;
|
||||
using xEventService.Configuration;
|
||||
using xEventService.Models;
|
||||
using xExceptions.Constants;
|
||||
using System.Threading.Tasks;
|
||||
using xEventService.Constants;
|
||||
using xEventService.Extensions;
|
||||
using xEventService.Interfaces;
|
||||
using xEventService.Models;
|
||||
using xExceptions.Constants;
|
||||
using xEventService.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace xEventService.Providers
|
||||
{
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
|
||||
<!-- Icon Handling -->
|
||||
<ItemGroup>
|
||||
<None Include="../../Documents/Resources/Images/favicon.png" Link="icon.png" Pack="true" PackagePath="\icon.png" />
|
||||
<None Include="../../Documents/Resources/Images/favicon.png" Link="icon.png" Pack="true"
|
||||
PackagePath="\icon.png" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Local Modules -->
|
||||
@@ -41,9 +42,9 @@
|
||||
|
||||
<!-- For XML Documentation Support -->
|
||||
<PropertyGroup>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user