public KinesisEventService(string name, IOptions <KinesisSettings> kinesisSettings, ILogger <HiarcEventServiceProvider> logger) { _name = name; _kinesisSettings = kinesisSettings.Value; _logger = logger; _region = RegionEndpoint.GetBySystemName(_kinesisSettings.RegionSystemName); }
private void ConfigureServices() { _eventServices = new List <IEventService>(); foreach (var es in _hiarcSettings.EventServices) { if (!es.Enabled) { continue; } if (es.Provider == AWS_KINESIS) { var settings = new KinesisSettings { AccessKeyId = ((dynamic)es.Config).AccessKeyId, SecretAccessKey = ((dynamic)es.Config).SecretAccessKey, RegionSystemName = ((dynamic)es.Config).RegionSystemName, Stream = ((dynamic)es.Config).Stream }; IOptions <KinesisSettings> kinesisSettings = Options.Create(settings); IEventService kinesisService = new KinesisEventService(es.Name, kinesisSettings, _logger); _eventServices.Add(kinesisService); } else if (es.Provider == AZURE_SERVICE_BUS) { var settings = new ServiceBusSettings { ConnectionString = ((dynamic)es.Config).ConnectionString, Topic = ((dynamic)es.Config).Topic }; IOptions <ServiceBusSettings> serviceBusSettings = Options.Create(settings); IEventService serviceBusService = new ServiceBusEventService(es.Name, serviceBusSettings, _logger); _eventServices.Add(serviceBusService); } else if (es.Provider == GOOGLE_PUBSUB) { var settings = new PubSubSettings { ServiceAccountCredential = ((dynamic)es.Config).ServiceAccountCredential, ProjectId = ((dynamic)es.Config).ProjectId, Topic = ((dynamic)es.Config).Topic }; IOptions <PubSubSettings> pubSubSettings = Options.Create(settings); IEventService pubSubService = new PubSubEventService(es.Name, pubSubSettings, _logger); _eventServices.Add(pubSubService); } else if (es.Provider == WEBHOOK) { var settings = new WebhookSettings { URL = ((dynamic)es.Config).URL, Secret = ((dynamic)es.Config).Secret }; IOptions <WebhookSettings> webhookSettings = Options.Create(settings); IEventService webhookService = new WebhookEventService(es.Name, webhookSettings, _logger); _eventServices.Add(webhookService); } else { throw new Exception($"Unsupported event service provider: {es.Provider}"); } } }