public NatsModuleBuilder(IServiceCollection services, NatsSettings natsSettings) : base(services) { _natsSettings = natsSettings; }
public static IServiceCollection AddNatsServices(this IServiceCollection services, NatsSettings natsSenderOptions) { return(services.AddTransient <INatsSerializer, NatsSerializer>() .AddSingleton <INatsConnectionFactory>(cf => { var serializer = (INatsSerializer)cf.GetService(typeof(INatsSerializer)); var natsOptions = ConnectionFactory.GetDefaultOptions(); natsOptions.Url = natsSenderOptions.Url; natsOptions.Timeout = 60000; natsOptions.User = natsSenderOptions.User; natsOptions.Password = natsSenderOptions.Password; return new NatsConnectionFactory(serializer, natsOptions); })); }