Esempio n. 1
0
        public Server(KafkaBusFeatureCollection features, IApplicationLifetime applicationLifetime, ILoggerFactory logFactory)
        {
            if (features == null)
            {
                throw new ArgumentNullException(nameof(features));
            }

            if (applicationLifetime == null)
            {
                throw new ArgumentNullException(nameof(applicationLifetime));
            }

            if (logFactory == null)
            {
                throw new ArgumentNullException(nameof(logFactory));
            }

            this._logFactory          = logFactory;
            this._applicationLifetime = applicationLifetime;
            this._logger = logFactory.CreateLogger <Server>();

            this.Features = features;

            Interlocked.Add(ref InstanceCount, 1);
        }
Esempio n. 2
0
        public static IServiceCollection AddKafkaBusServer(this IServiceCollection services, IServerInformation information)
        {
            var serverFeatures = new KafkaBusFeatureCollection();

            serverFeatures.Set <IServerInformation>(information);
            serverFeatures.Set <IServerAddressesFeature>(information);
            services.AddSingleton(serverFeatures);
            services.AddTransient <Server>();
            return(services);
        }