public PublishService( ProducerSettings producerSettings, IOptionsSnapshot <PublishSettings <TMessage> > publishSettings, string topicName) { _publishSettings = publishSettings.Get(topicName); _producerSettings = producerSettings; _topicName = topicName; }
public IPublisher Register <TMessage>(string topicName, Action <PublishSettings <TMessage> > options) { _services.Configure <PublishSettings <TMessage> >(topicName, options); _services.AddScoped <IPublishService <TMessage> >(provider => { var producerSettings = new ProducerSettings(); _producerSettingsAction?.Invoke(producerSettings); var subscribeOptions = provider.GetRequiredService <IOptionsSnapshot <PublishSettings <TMessage> > >(); return(new PublishService <TMessage>( producerSettings, subscribeOptions, topicName )); }); return(this); }