public IEnumerable <Assembly> GetAssemblies()
        {
            Assembly assembly = ThriftServiceHelper.GetThriftServiceAssembly();

            if (assembly == null)
            {
                return(Enumerable.Empty <Assembly>());
            }

            return(new Assembly[] { assembly });
        }
        public virtual AgentCheckRegistration CreateCheck()
        {
            string applicationName = ThriftServiceHelper.GetApplicationName();

            if (string.IsNullOrWhiteSpace(applicationName))
            {
                throw new Exception("ApplicationName不存在,无法设置健康检查ID");
            }
            applicationName = applicationName.ToLower();

            return(new AgentCheckRegistration
            {
                ID = applicationName + ".check",
                Name = applicationName,
                TCP = ServiceCheckConfig.Address + ":" + ServiceCheckConfig.Port,
                Interval = ServiceCheckConfig.Interval,
                Timeout = ServiceCheckConfig.Timeout
            });
        }
        protected virtual void StartService(IGrouping <int, ThriftService> group)
        {
            TMultiplexedProcessor multiplexedProcessor = new TMultiplexedProcessor();
            IServiceActivator     serviceActivator     = GlobalSetting.Container.GetService <IServiceActivator>();

            if (serviceActivator == null)
            {
                throw new NullReferenceException("未设置IServiceActivator接口");
            }
            foreach (ThriftService service in group)
            {
                object instance = serviceActivator.Create(service.ServiceType);
                if (instance == null)
                {
                    throw new NullReferenceException($"无法创建服务{service.ServiceType.FullName}");
                }
                Type processorType = ThriftServiceHelper.GetProcessorType(service.ServiceType);
                if (processorType == null)
                {
                    throw new NullReferenceException($"无法找到服务{service.ServiceType.FullName}对应的Processor类");
                }
                TProcessor processor = ThriftServiceHelper.CreateProcessor(processorType, instance);
                if (processor == null)
                {
                    throw new NullReferenceException($"无法创建Processor{processorType.FullName}");
                }
                multiplexedProcessor.RegisterProcessor(service.Name, processor);
            }
            TServerTransport serverTransport = new TServerSocket(group.Key);

            serverTransport.Listen();
            TServer server = new TThreadPoolServer(multiplexedProcessor, serverTransport);

            _servers.Add(server);
            Task.Run(() => server.Serve());
        }