public ScopedServer(TProtocolFactory protocolFactory, object service) { ThriftServiceProcessor processor = new ThriftServiceProcessor(services: service); ThriftServerDef def = new ThriftServerDef(processor, protocolFactory, serverPort: 0); server = new NettyServerTransport(def, new NettyServerConfig(1, 1)); server.StartAsync().GetAwaiter().GetResult(); }
public ThriftServer(NettyServerConfig nettyServerConfig, ThriftServerDef thriftServerDef, ILoggerFactory loggerFactory = null) { Guard.ArgumentNotNull(nettyServerConfig, nameof(nettyServerConfig)); Guard.ArgumentNotNull(thriftServerDef, nameof(thriftServerDef)); _eventLocked = new ManualResetEvent(true); _logger = loggerFactory?.CreateLogger <ThriftServer>() ?? (ILogger)NullLogger.Instance; _transport = new NettyServerTransport(thriftServerDef, nettyServerConfig); }
public ServerTester Invoke() { ThriftServiceProcessor processor = new ThriftServiceProcessor(loggerFactory: null, services: new SimpleService()); bossExecutor = new MultithreadEventLoopGroup(1); ioWorkerExecutor = new MultithreadEventLoopGroup(1); ThriftServerDef serverDef = new ThriftServerDef(processor, new TBinaryProtocol.Factory()); NettyServerConfig serverConfig = new NettyServerConfig(bossGroup: bossExecutor, workerGroup: ioWorkerExecutor); Server = new ThriftServer(serverConfig, serverDef); return(this); }
public ThriftServer( INiftyProcessor processor, ThriftServerConfig serverConfig, IDictionary <String, IThriftFrameCodecFactory> availableFrameCodecFactories, IDictionary <String, TDuplexProtocolFactory> availableProtocolFactories, SslConfig sslConfig = null, ILoggerFactory loggerFactory = null ) { Guard.ArgumentNotNull(serverConfig, nameof(serverConfig)); Guard.ArgumentNotNull(availableFrameCodecFactories, nameof(availableFrameCodecFactories)); Guard.ArgumentNotNull(availableProtocolFactories, nameof(availableProtocolFactories)); Guard.ArgumentCondition(availableFrameCodecFactories.ContainsKey(serverConfig.TransportName), $"No available server transport named {serverConfig.TransportName}"); Guard.ArgumentCondition(availableProtocolFactories.ContainsKey(serverConfig.ProtocolName), $"No available server protocol named {serverConfig.ProtocolName}"); _eventLocked = new ManualResetEvent(true); _logger = loggerFactory?.CreateLogger <ThriftServer>() ?? (ILogger)NullLogger.Instance; ThriftServerDef def = new ThriftServerDef( new DelegateNiftyProcessorFactory(t => processor), availableProtocolFactories[serverConfig.ProtocolName], "thrift", serverConfig.BindingAddress, serverConfig.Port, serverConfig.MaxFrameSizeBytes, serverConfig.MaxQueuedResponsesPerConnection, serverConfig.ConnectionLimit ?? int.MaxValue, availableFrameCodecFactories[serverConfig.TransportName], serverConfig.IdleConnectionTimeout, serverConfig.TaskExpirationTimeout != TimeSpan.Zero ? serverConfig.TaskExpirationTimeout : (TimeSpan?)null, serverConfig.QueueTimeout != TimeSpan.Zero ? serverConfig.QueueTimeout : (TimeSpan?)null, sslConfig ); NettyServerConfig config = new NettyServerConfig(new HashedWheelTimer(), new MultithreadEventLoopGroup(serverConfig.AcceptorThreadCount), new MultithreadEventLoopGroup(serverConfig.WorkerThreadCount), serverConfig.IOThreadCount,//20170515陈慎远临时添加 null, loggerFactory); //NettyServerConfig config = new NettyServerConfig(timer:new HashedWheelTimer(), // bossGroup: new MultithreadEventLoopGroup(serverConfig.AcceptorThreadCount), // ioThreadCount:1); _transport = new NettyServerTransport(def, config); }