Esempio n. 1
0
        // For testing
        public LibuvConnectionListener(LibuvFunctions uv, LibuvTransportContext context, EndPoint endPoint)
        {
            Libuv            = uv;
            TransportContext = context;

            EndPoint = endPoint;
        }
Esempio n. 2
0
        // For testing
        public LibuvTransport(LibuvFunctions uv, LibuvTransportContext context, IEndPointInformation endPointInformation)
        {
            Libuv            = uv;
            TransportContext = context;

            _endPointInformation = endPointInformation;
        }
        public ITransport Create(IEndPointInformation endPointInformation, IConnectionDispatcher dispatcher)
        {
            var transportContext = new LibuvTransportContext
            {
                Options              = _baseTransportContext.Options,
                AppLifetime          = _baseTransportContext.AppLifetime,
                Log                  = _baseTransportContext.Log,
                ConnectionDispatcher = dispatcher
            };

            return(new LibuvTransport(transportContext, endPointInformation));
        }
        public LibuvTransportFactory(
#pragma warning disable CS0618
            IOptions <LibuvTransportOptions> options,
#pragma warning restore CS0618
            IHostApplicationLifetime applicationLifetime,
            ILoggerFactory loggerFactory)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (applicationLifetime == null)
            {
                throw new ArgumentNullException(nameof(applicationLifetime));
            }
            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            var logger = loggerFactory.CreateLogger("Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv");
            var trace  = new LibuvTrace(logger);

#pragma warning disable CS0618
            var threadCount = options.Value.ThreadCount;
#pragma warning restore CS0618

            if (threadCount <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(threadCount),
                                                      threadCount,
                                                      "ThreadCount must be positive.");
            }

            if (!LibuvConstants.ECONNRESET.HasValue)
            {
                trace.LogWarning("Unable to determine ECONNRESET value on this platform.");
            }

            if (!LibuvConstants.EADDRINUSE.HasValue)
            {
                trace.LogWarning("Unable to determine EADDRINUSE value on this platform.");
            }

            _baseTransportContext = new LibuvTransportContext
            {
                Options     = options.Value,
                AppLifetime = applicationLifetime,
                Log         = trace,
            };
        }
        public async ValueTask <IConnectionListener> BindAsync(EndPoint endpoint, CancellationToken cancellationToken = default)
        {
            var transportContext = new LibuvTransportContext
            {
                Options     = _baseTransportContext.Options,
                AppLifetime = _baseTransportContext.AppLifetime,
                Log         = _baseTransportContext.Log
            };

            var transport = new LibuvConnectionListener(transportContext, endpoint);
            await transport.BindAsync();

            return(transport);
        }
Esempio n. 6
0
 public LibuvConnectionListener(LibuvTransportContext context, EndPoint endPoint)
     : this(new LibuvFunctions(), context, endPoint)
 {
 }
Esempio n. 7
0
 public ListenerContext(LibuvTransportContext transportContext)
 {
     TransportContext = transportContext;
 }
Esempio n. 8
0
 public ListenerPrimary(LibuvTransportContext transportContext) : base(transportContext)
 {
 }
 public ListenerSecondary(LibuvTransportContext transportContext) : base(transportContext) => _ptr = Marshal.AllocHGlobal(4);
Esempio n. 10
0
 public LibuvThread(LibuvFunctions libuv, LibuvTransportContext libuvTransportContext, int maxLoops = 8)
     : this(libuv, libuvTransportContext.AppLifetime, libuvTransportContext.Options.MemoryPoolFactory(), libuvTransportContext.Log, maxLoops)
 {
 }
Esempio n. 11
0
 public LibuvTransport(LibuvTransportContext context, IEndPointInformation endPointInformation)
     : this(new LibuvFunctions(), context, endPointInformation)
 {
 }