コード例 #1
0
ファイル: ThriftServerDef.cs プロジェクト: ysj123688/Thrifty
 public ThriftServerDef(
     INiftyProcessorFactory processorFactory,
     TProtocolFactory protocolFactory,
     String name             = null,
     String host             = null,
     int serverPort          = 5858,
     long maxFrameSize       = DefaultMaxFrameSize,
     int queuedResponseLimit = 16,
     int maxConnections      = int.MaxValue,
     IThriftFrameCodecFactory thriftFrameCodecFactory = null,
     TimeSpan?clientIdleTimeout = null,
     TimeSpan?taskTimeout       = null,
     TimeSpan?queueTimeout      = null,
     SslConfig sslConfig        = null
     )
     : this(processorFactory,
            TDuplexProtocolFactory.FromSingleFactory(protocolFactory),
            name,
            host,
            serverPort,
            maxFrameSize,
            queuedResponseLimit,
            maxConnections,
            thriftFrameCodecFactory,
            clientIdleTimeout,
            taskTimeout,
            queueTimeout,
            sslConfig)
 {
 }
コード例 #2
0
ファイル: ThriftServerDef.cs プロジェクト: ysj123688/Thrifty
        public ThriftServerDef(
            INiftyProcessorFactory processorFactory,
            TDuplexProtocolFactory protocolFactory,
            String name             = null,
            String host             = null,
            int serverPort          = 5858,
            long maxFrameSize       = DefaultMaxFrameSize,
            int queuedResponseLimit = 16,
            int maxConnections      = int.MaxValue,
            IThriftFrameCodecFactory thriftFrameCodecFactory = null,
            TimeSpan?clientIdleTimeout = null,
            TimeSpan?taskTimeout       = null,
            TimeSpan?queueTimeout      = null,
            SslConfig sslConfig        = null
            )
        {
            Guard.ArgumentNotNull(protocolFactory, nameof(protocolFactory));

            this.Name                    = String.IsNullOrWhiteSpace(name) ? ($"nifty-{Interlocked.Increment(ref _globalId)}") : name;
            this.Host                    = host;
            this.ServerPort              = serverPort;
            this.MaxFrameSize            = maxFrameSize;
            this.MaxConnections          = maxConnections;
            this.QueuedResponseLimit     = queuedResponseLimit;
            this.ProcessorFactory        = processorFactory;
            this.DuplexProtocolFactory   = protocolFactory;
            this.ClientIdleTimeout       = clientIdleTimeout ?? TimeSpan.Zero;
            this.TaskTimeout             = taskTimeout ?? TimeSpan.Zero;
            this.QueueTimeout            = queueTimeout ?? TimeSpan.Zero;
            this.ThriftFrameCodecFactory = thriftFrameCodecFactory ?? new DefaultThriftFrameCodecFactory();
            //this.Executor = executor ?? new DotNetty.Common.Concurrency.SingleThreadEventExecutor;
            //this.SecurityFactory = securityFactory;
            this.SslConfig = sslConfig;
        }
コード例 #3
0
 protected AbstractClientChannel(IChannel nettyChannel, ITimer timer, TDuplexProtocolFactory protocolFactory, ILoggerFactory loggerFactory = null)
 {
     this._requestMap       = new Dictionary <int, Request>();
     this.NettyChannel      = nettyChannel;
     this._timer            = timer;
     this.ProtocolFactory   = protocolFactory;
     this._logger           = loggerFactory?.CreateLogger(this.GetType()) ?? NullLogger.Instance;
     this._readerWriterLock = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion);
 }
コード例 #4
0
ファイル: ThriftServer.cs プロジェクト: ysj123688/Thrifty
        static ThriftServer()
        {
            var factoryBuilder = ImmutableDictionary.CreateBuilder <String, TDuplexProtocolFactory>();

            factoryBuilder.Add("binary", TDuplexProtocolFactory.FromSingleFactory(new TBinaryProtocol.Factory()));
            factoryBuilder.Add("compact", TDuplexProtocolFactory.FromSingleFactory(new TCompactProtocol.Factory()));
            DefaultProtocolFactories = factoryBuilder.ToImmutableDictionary();

            var codecBuilder = ImmutableDictionary.CreateBuilder <String, IThriftFrameCodecFactory>();

            codecBuilder.Add("buffered", new DefaultThriftFrameCodecFactory());
            codecBuilder.Add("framed", new DefaultThriftFrameCodecFactory());
            DefaultFrameCodecFactories = codecBuilder.ToImmutableDictionary();
        }
コード例 #5
0
ファイル: NiftyDispatcher.cs プロジェクト: ysj123688/Thrifty
        public NiftyDispatcher(ThriftServerDef serverDef, ITimer timer, int?ioThreadCount, ILoggerFactory loggerFactory = null)
        {
            Guard.ArgumentNotNull(timer, nameof(timer));
            this._taskTimeoutTimer = timer;

            _logger = loggerFactory?.CreateLogger(this.GetType()) ?? NullLogger.Instance;
            this._processorFactory = serverDef.ProcessorFactory;
            //this.exe = serverDef.Executor;
            this._taskTimeoutMillis     = (long)serverDef.TaskTimeout.TotalMilliseconds;
            this._queueTimeoutMillis    = (long)serverDef.QueueTimeout.TotalMilliseconds;
            this._queuedResponseLimit   = serverDef.QueuedResponseLimit;
            this._duplexProtocolFactory = serverDef.DuplexProtocolFactory;

            if (ioThreadCount.HasValue && ioThreadCount.Value > 0)
            {
                LimitedConcurrencyLevelTaskScheduler limitedScheduler = new LimitedConcurrencyLevelTaskScheduler(ioThreadCount.Value);
                _factory = new TaskFactory(limitedScheduler);
            }
            else
            {
                _factory = Task.Factory;
            }
        }
コード例 #6
0
 protected static TDuplexProtocolFactory GetDefaultProtocolFactory()
 {
     return(TDuplexProtocolFactory.FromSingleFactory(new TBinaryProtocol.Factory()));
 }
コード例 #7
0
 public AbstractClientConnector(EndPoint address, TDuplexProtocolFactory protocolFactory)
 {
     this.ServerAddress   = address;
     this.ProtocolFactory = protocolFactory;
 }
コード例 #8
0
 public UnframedClientChannel(IChannel nettyChannel, ITimer timer, TDuplexProtocolFactory protocolFactory, ILoggerFactory loggerFactory = null) :
     base(nettyChannel, timer, protocolFactory, loggerFactory)
 {
 }
コード例 #9
0
 public UnframedClientConnector(EndPoint address, TDuplexProtocolFactory protocolFactory) : base(address, protocolFactory)
 {
 }
コード例 #10
0
 public FramedClientConnector(EndPoint address, TDuplexProtocolFactory protocolFactory, ILoggerFactory loggerFactory = null) : base(address, protocolFactory)
 {
     Guard.ArgumentNotNull(address, nameof(address));
     _loggerFactory = loggerFactory;
     _logger        = loggerFactory?.CreateLogger(this.GetType()) ?? NullLogger.Instance;
 }
コード例 #11
0
 public FramedClientConnector(EndPoint address, TProtocolFactory tFactory, ILoggerFactory loggerFactory = null)
     : this(address, TDuplexProtocolFactory.FromSingleFactory(tFactory), loggerFactory)
 {
 }
コード例 #12
0
 public FramedClientConnector(string hostName, int port, TDuplexProtocolFactory factory, ILoggerFactory loggerFactory = null)
     : this(GetEndPoint(hostName, port), factory, loggerFactory)
 {
 }