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.Models;
|
||||||
|
using xEventService.Constants;
|
||||||
|
|
||||||
namespace xEventService.Configuration
|
namespace xEventService.Configuration
|
||||||
{
|
{
|
||||||
|
|||||||
+4
-155
@@ -1,13 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using xCommons.Extensions;
|
using xCommons.Extensions;
|
||||||
using xEventService.Configuration;
|
using xExceptions.Constants;
|
||||||
using xEventService.Constants;
|
using xEventService.Constants;
|
||||||
using xEventService.Extensions;
|
using xEventService.Extensions;
|
||||||
using xEventService.Interfaces;
|
using xEventService.Configuration;
|
||||||
using xEventService.Providers;
|
using Microsoft.Extensions.Configuration;
|
||||||
using xExceptions.Constants;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace xEventService.DI
|
namespace xEventService.DI
|
||||||
{
|
{
|
||||||
@@ -76,104 +74,6 @@ namespace xEventService.DI
|
|||||||
services.AddSingleton(configuration);
|
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 ...
|
#region Private ...
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -189,57 +89,6 @@ namespace xEventService.DI
|
|||||||
{
|
{
|
||||||
Console.WriteLine($"{XLogTag} => {message}");
|
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
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using xCommons.Extensions;
|
using xCommons.Extensions;
|
||||||
using xEventService.Configuration;
|
|
||||||
using xEventService.Constants;
|
|
||||||
using xEventService.Models;
|
using xEventService.Models;
|
||||||
using xExceptions.Constants;
|
using xExceptions.Constants;
|
||||||
|
using xEventService.Constants;
|
||||||
|
using xEventService.Configuration;
|
||||||
|
|
||||||
namespace xEventService.Extensions
|
namespace xEventService.Extensions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using xEventService.Models;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using xEventService.Constants;
|
using xEventService.Constants;
|
||||||
using xEventService.Models;
|
|
||||||
|
|
||||||
namespace xEventService.Interfaces
|
namespace xEventService.Interfaces
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using xEventService.Models;
|
using xEventService.Models;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace xEventService.Interfaces
|
namespace xEventService.Interfaces
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace xEventService.Models
|
namespace xEventService.Models
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using xCommons.Extensions;
|
|
||||||
using xCommons.Providers;
|
using xCommons.Providers;
|
||||||
using xEventService.Configuration;
|
using xCommons.Extensions;
|
||||||
|
using xExceptions.Constants;
|
||||||
using xEventService.Constants;
|
using xEventService.Constants;
|
||||||
using xEventService.Extensions;
|
using xEventService.Extensions;
|
||||||
using xExceptions.Constants;
|
using xEventService.Configuration;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace xEventService.Providers
|
namespace xEventService.Providers
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using xCommons.Extensions;
|
using xCommons.Extensions;
|
||||||
using xEventService.Configuration;
|
|
||||||
using xEventService.Extensions;
|
|
||||||
using xExceptions.Constants;
|
using xExceptions.Constants;
|
||||||
|
using xEventService.Extensions;
|
||||||
|
using xEventService.Configuration;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace xEventService.Providers
|
namespace xEventService.Providers
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using xCommons.Extensions;
|
using xCommons.Extensions;
|
||||||
using xEventService.Configuration;
|
using xEventService.Models;
|
||||||
|
using xExceptions.Constants;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using xEventService.Constants;
|
using xEventService.Constants;
|
||||||
using xEventService.Extensions;
|
using xEventService.Extensions;
|
||||||
using xEventService.Interfaces;
|
using xEventService.Interfaces;
|
||||||
using xEventService.Models;
|
using xEventService.Configuration;
|
||||||
using xExceptions.Constants;
|
|
||||||
|
|
||||||
namespace xEventService.Providers
|
namespace xEventService.Providers
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Confluent.Kafka;
|
using Confluent.Kafka;
|
||||||
using Microsoft.Extensions.Logging;
|
using System.Threading;
|
||||||
using xCommons.Extensions;
|
using xCommons.Extensions;
|
||||||
using xEventService.Configuration;
|
|
||||||
using xEventService.Constants;
|
|
||||||
using xEventService.Extensions;
|
|
||||||
using xEventService.Models;
|
using xEventService.Models;
|
||||||
using xExceptions.Constants;
|
using xExceptions.Constants;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using xEventService.Constants;
|
||||||
|
using xEventService.Extensions;
|
||||||
|
using xEventService.Configuration;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace xEventService.Providers
|
namespace xEventService.Providers
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using Confluent.Kafka;
|
||||||
|
using System.Threading;
|
||||||
using xCommons.Extensions;
|
using xCommons.Extensions;
|
||||||
|
using xEventService.Models;
|
||||||
using xExceptions.Constants;
|
using xExceptions.Constants;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using xEventService.Constants;
|
||||||
using xEventService.Extensions;
|
using xEventService.Extensions;
|
||||||
using xEventService.Interfaces;
|
using xEventService.Interfaces;
|
||||||
using xEventService.Configuration;
|
using xEventService.Configuration;
|
||||||
using xEventService.Models;
|
|
||||||
using Confluent.Kafka;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Threading;
|
|
||||||
using xEventService.Constants;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace xEventService.Providers
|
namespace xEventService.Providers
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using RabbitMQ.Client;
|
using RabbitMQ.Client;
|
||||||
using RabbitMQ.Client.Events;
|
using System.Threading;
|
||||||
using xCommons.Extensions;
|
using xCommons.Extensions;
|
||||||
using xEventService.Configuration;
|
|
||||||
using xEventService.Constants;
|
|
||||||
using xEventService.Extensions;
|
|
||||||
using xEventService.Models;
|
using xEventService.Models;
|
||||||
using xExceptions.Constants;
|
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
|
namespace xEventService.Providers
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using RabbitMQ.Client;
|
using RabbitMQ.Client;
|
||||||
|
using System.Threading;
|
||||||
using xCommons.Extensions;
|
using xCommons.Extensions;
|
||||||
using xEventService.Configuration;
|
using xEventService.Models;
|
||||||
|
using xExceptions.Constants;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using xEventService.Constants;
|
using xEventService.Constants;
|
||||||
using xEventService.Extensions;
|
using xEventService.Extensions;
|
||||||
using xEventService.Interfaces;
|
using xEventService.Interfaces;
|
||||||
using xEventService.Models;
|
using xEventService.Configuration;
|
||||||
using xExceptions.Constants;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace xEventService.Providers
|
namespace xEventService.Providers
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
|
using NetMQ;
|
||||||
using System;
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using NetMQ;
|
|
||||||
using NetMQ.Sockets;
|
using NetMQ.Sockets;
|
||||||
|
using System.Threading;
|
||||||
using xCommons.Extensions;
|
using xCommons.Extensions;
|
||||||
using xEventService.Configuration;
|
|
||||||
using xEventService.Constants;
|
|
||||||
using xEventService.Extensions;
|
|
||||||
using xEventService.Models;
|
using xEventService.Models;
|
||||||
using xExceptions.Constants;
|
using xExceptions.Constants;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using xEventService.Constants;
|
||||||
|
using xEventService.Extensions;
|
||||||
|
using xEventService.Configuration;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace xEventService.Providers
|
namespace xEventService.Providers
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
|
using NetMQ;
|
||||||
using System;
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using NetMQ;
|
|
||||||
using NetMQ.Sockets;
|
using NetMQ.Sockets;
|
||||||
|
using System.Threading;
|
||||||
using xCommons.Extensions;
|
using xCommons.Extensions;
|
||||||
using xEventService.Configuration;
|
using xEventService.Models;
|
||||||
|
using xExceptions.Constants;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using xEventService.Constants;
|
using xEventService.Constants;
|
||||||
using xEventService.Extensions;
|
using xEventService.Extensions;
|
||||||
using xEventService.Interfaces;
|
using xEventService.Interfaces;
|
||||||
using xEventService.Models;
|
using xEventService.Configuration;
|
||||||
using xExceptions.Constants;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace xEventService.Providers
|
namespace xEventService.Providers
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,8 @@
|
|||||||
|
|
||||||
<!-- Icon Handling -->
|
<!-- Icon Handling -->
|
||||||
<ItemGroup>
|
<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>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Local Modules -->
|
<!-- Local Modules -->
|
||||||
@@ -41,9 +42,9 @@
|
|||||||
|
|
||||||
<!-- For XML Documentation Support -->
|
<!-- For XML Documentation Support -->
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
|
||||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||||
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
|
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
Reference in New Issue
Block a user