using System; using xCommons.Providers; using xCommons.Extensions; using xExceptions.Constants; using xEventService.Constants; using xEventService.Extensions; using xEventService.Configuration; using Microsoft.Extensions.Logging; namespace xEventService.Providers { /// /// Base Event Consumer Service ... /// public abstract class XBaseEventConsumerBackgroundService : XResumableBackgroundService { /// /// Consumed Topic Messages ... /// protected readonly string topic; /// /// Allowed Senders ... /// protected readonly string[] allowedSenders; /// /// Allowed Actions ... /// protected readonly string[] allowedActions; /// /// Configuration ... /// protected readonly XEventServiceConfiguration configuration; protected XBaseEventConsumerBackgroundService( string[] allowedActions, string[] allowedSenders, IServiceProvider serviceProvider, XEventServiceConfiguration configuration, ILogger logger, string topic = XEventServiceConstants.XDefaultTopic ) : base(serviceProvider, logger) { // // Validate Actions ... if (!allowedActions .IsAllowedCollection() || !allowedSenders .IsAllowedCollection() || !configuration.IsValid() ) { XException.InvalidArgs.Throw(); } // this.topic = topic; this.configuration = configuration; this.allowedActions = allowedActions; this.allowedSenders = allowedSenders; } } }