protected virtual void FillClientConfig(ClientConfig config)
        {
            ThriftClientConfig thriftConfig = config as ThriftClientConfig;

            if (thriftConfig != null)
            {
                //thriftConfig.ConnectionLimit = thriftConfig.ConnectionLimit ?? 50;
                //thriftConfig.ConnectionOverdueInterval = thriftConfig.ConnectionOverdueInterval ?? TimeSpan.FromMinutes(5);
                //thriftConfig.WaitFreeMillisecond = thriftConfig.WaitFreeMillisecond ?? 1000;
            }
        }
예제 #2
0
        protected virtual void Init()
        {
            ThriftServiceConfiguration configuration = new ThriftServiceConfiguration();
            ServiceConfig      serviceConfig         = configuration.GetServiceConfig();
            ThriftClientConfig clientConfig          = serviceConfig.Client as ThriftClientConfig;
            ThriftServerConfig serverConfig          = serviceConfig.Server as ThriftServerConfig;

            if (clientConfig == null)
            {
                throw new Exception("ClientConfig必须为ThriftClientConfig类型");
            }
            if (serverConfig == null)
            {
                throw new Exception("ServerConfig必须为ThriftServerConfig类型");
            }
            ThriftServiceRegistry serviceRegistry = new ThriftServiceRegistry(serviceConfig.RegistrationCenter, serverConfig.WaitConsulTime.Value);

            _cache.Add(typeof(IServiceConfiguration), configuration);
            _cache.Add(typeof(IServiceRegistry), serviceRegistry);
            _cache.Add(typeof(IServiceHealthCheck), serviceRegistry);
            _cache.Add(typeof(IServiceHealthCheckCreator), new ServiceHealthCheckCreator(serverConfig.ServiceCheck));
            _cache.Add(typeof(IServerController), new ThriftServerController());
            _cache.Add(typeof(IServiceActivator), new ThriftServiceActivator());

            _cache.Add(typeof(IServiceAssembliesResolver), new ThriftServiceAssembliesResolver());
            _cache.Add(typeof(IServiceFinder), new ThriftServiceFinder());
            _cache.Add(typeof(IServiceDiscoverer), new ThriftServiceDiscoverer());
            _cache.Add(typeof(IThriftClientActivator), new ThriftClientActivator());
            _cache.Add(typeof(IThriftConnectionPool), new FreshConnectionPool());
            //_cache.Add(typeof(IThriftConnectionPool),
            //    new ThriftConnectionPool(clientConfig.ConnectionLimit.Value,
            //                                             clientConfig.WaitFreeMillisecond.Value,
            //                                             clientConfig.WaitFreeTimes.Value,
            //                                             clientConfig.ConnectionOverdueInterval.Value));
            _cache.Add(typeof(IClientController), new ThriftClientController());
            _cache.Add(typeof(IDynamicProxyBuilder), new ThriftDynamicProxy("Mistong.RPCFramework.Thrift"));
            this.AddFilter(new FilterInfo {
                Instance = new MissingResultExceptionFilter(), Order = int.MaxValue
            });
        }