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 { /// /// Base Event Consumer Service ... /// public abstract class XBaseEventConsumerBackgroundService : XResumableBackgroundService { /// /// Consumed Topic Messages ... /// protected readonly string topic; /// /// Allowed Senders ... /// public readonly string[] allowedSenders; /// /// Allowed Actions ... /// public 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( 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; } } }