last works on Event Service ...
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xCommons.Extensions;
|
||||
using xCommons.Providers;
|
||||
using xEventService.Configuration;
|
||||
using xEventService.Constants;
|
||||
using xEventService.Extensions;
|
||||
using xExceptions.Constants;
|
||||
|
||||
namespace xEventService.Providers
|
||||
{
|
||||
/// <summary>
|
||||
/// Base Event Consumer Service ...
|
||||
/// </summary>
|
||||
public abstract class XBaseEventConsumerBackgroundService : XResumableBackgroundService
|
||||
{
|
||||
/// <summary>
|
||||
/// Consumed Topic Messages ...
|
||||
/// </summary>
|
||||
protected readonly string topic;
|
||||
|
||||
/// <summary>
|
||||
/// Allowed Senders ...
|
||||
/// </summary>
|
||||
public readonly string[] allowedSenders;
|
||||
|
||||
/// <summary>
|
||||
/// Allowed Actions ...
|
||||
/// </summary>
|
||||
public readonly string[] allowedActions;
|
||||
|
||||
/// <summary>
|
||||
/// Configuration ...
|
||||
/// </summary>
|
||||
protected readonly XEventServiceConfiguration configuration;
|
||||
|
||||
protected XBaseEventConsumerBackgroundService(
|
||||
string[] allowedActions,
|
||||
string[] allowedSenders,
|
||||
IServiceProvider serviceProvider,
|
||||
XEventServiceConfiguration configuration,
|
||||
ILogger<XResumableBackgroundService> logger,
|
||||
string topic = XEventServiceConstants.XDefaultTopic
|
||||
) : base(
|
||||
logger: logger,
|
||||
serviceProvider: serviceProvider
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Actions ...
|
||||
if (!allowedActions
|
||||
.IsAllowedCollection() ||
|
||||
!allowedSenders
|
||||
.IsAllowedCollection() ||
|
||||
!configuration.IsValid()
|
||||
)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
this.topic = topic;
|
||||
this.configuration = configuration;
|
||||
this.allowedActions = allowedActions;
|
||||
this.allowedSenders = allowedSenders;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user