示例#1
0
 public void Open()
 {
     BufferPool.BUFFER_SIZE   = AgentBufferSize;
     BufferPool.POOL_MAX_SIZE = AgentBufferPoolSize;
     HttpServer[GATEWAY_TAG]  = this;
     HttpServer.ModuleManager.AssemblyLoding += (o, e) =>
     {
         LoadPlugin(e.Assembly);
     };
     if (HttpServer.Options.CacheLogMaxSize < 1000)
     {
         HttpServer.Options.CacheLogMaxSize = 1000;
     }
     if (HttpServer.Options.BufferPoolMaxMemory < 1024)
     {
         HttpServer.Options.BufferPoolMaxMemory = 1024;
     }
     if (HttpServer.Options.BufferSize < 1024 * 8)
     {
         HttpServer.Options.BufferSize = 1024 * 8;
     }
     mIOQueue = new BeetleX.Dispatchs.DispatchCenter <Tuple <UrlRouteAgent, HttpRequest, HttpResponse> >(OnRouteExecute,
                                                                                                         ThreadQueues);
     HttpServer.Options.UrlIgnoreCase = false;
     // HttpServer.Options.IOQueueEnabled = true;
     HttpServer.Open();
     HttpServer.HttpRequesting += OnRequest;
     LoadConfig();
     //GatewayController controller = new GatewayController(this);
     //HttpServer.ActionFactory.Register(controller);
     PluginCenter.Load(typeof(Gateway).Assembly);
     HttpServer.Log(BeetleX.EventArgs.LogType.Info, $"Gateway server started [v:{this.GetType().Assembly.GetName().Version}]");
     mVerifyTimer = new Timer(OnVerifyTimer, null, 1000, 1000);
 }
示例#2
0
        public Gateway()
        {
            HttpServer = new HttpApiServer();
            Filters    = new Filters.FilterCenter(this);
            Routes     = new Routes.RouteCenter(this);
            Agents     = new Servers.ServerCenter(this);
            HttpServer.Options.IOQueueEnabled = true;
            HttpServer.Options.UrlIgnoreCase  = false;
            AgentMaxSocketError     = 5;
            MaxStatsUrls            = 1000;
            AgentMaxConnection      = 300;
            AgentRequestQueueLength = 2000;
            int threads = (Environment.ProcessorCount / 2);

            if (threads == 0)
            {
                threads = 1;
            }
            multiThreadDispatcher = new BeetleX.Dispatchs.DispatchCenter <RequestAgent>(OnExecuteRequest,
                                                                                        Math.Min(threads, 16));
            AgentBufferSize     = 1024 * 8;
            AgentBufferPoolSize = 1024 * 200;
        }
示例#3
0
        public void Open()
        {
            HttpServer[GATEWAY_TAG] = this;
            HttpServer.ModuleManager.AssemblyLoding += (o, e) =>
            {
                LoadPlugin(e.Assembly);
            };
            if (HttpServer.Options.CacheLogMaxSize < 1000)
            {
                HttpServer.Options.CacheLogMaxSize = 1000;
            }
            mIOQueue = new BeetleX.Dispatchs.DispatchCenter <Tuple <UrlRouteAgent, HttpRequest, HttpResponse> >(OnRouteExecute,
                                                                                                                ThreadQueues);
            HttpServer.Options.UrlIgnoreCase = false;
            HttpServer.Options.AgentRewrite  = true;
            HttpServer.Open();
            HttpServer.HttpRequesting += OnRequest;
            LoadConfig();

            PluginCenter.Load(typeof(Gateway).Assembly);
            HttpServer.Log(BeetleX.EventArgs.LogType.Info, $"Gateway server started [v:{this.GetType().Assembly.GetName().Version}]");
            mVerifyTimer = new Timer(OnVerifyTimer, null, 1000, 1000);
        }
示例#4
0
        public void Open()
        {
            HttpServer[GATEWAY_TAG] = this;
            HttpServer.ModuleManager.AssemblyLoding += (o, e) =>
            {
                LoadPlugin(e.Assembly);
            };
            if (HttpServer.Options.CacheLogMaxSize < 1000)
            {
                HttpServer.Options.CacheLogMaxSize = 1000;
            }
            mIOQueue = new BeetleX.Dispatchs.DispatchCenter <Tuple <UrlRouteAgent, HttpRequest, HttpResponse> >(OnRouteExecute,
                                                                                                                ThreadQueues);
            // HttpServer.Options.UrlIgnoreCase = false;
            if (HttpServer.Options.MaxWaitQueue > 0 && HttpServer.Options.MaxWaitQueue < 500)
            {
                HttpServer.Options.MaxWaitQueue = 1000;
            }
            HttpServer.Options.AgentRewrite = true;
            HttpServer.FrameSerializer      = new WSAgents.WSAgentDataFrameSerializer();
            if (WSEnabled)
            {
                HttpServer.WebSocketReceive = OnWebsocketReceive;
            }
            HttpServer.WriteLogo = OutputLogo;
            HttpServer.Open();
            HttpServer.HttpRequesting += OnHttpRequest;
            HttpServer.HttpDisconnect += OnHttpDisconnect;
            LoadConfig();
            HeaderTypeFactory.SERVAR_HEADER_BYTES = Encoding.ASCII.GetBytes("Server :" + GATEWAY_VERSION + "\r\n");
            PluginCenter.Load(typeof(Gateway).Assembly);

            mVerifyTimer = new Timer(OnVerifyTimer, null, 1000, 1000);

            ProxyBufferPool = new BufferPool(BufferSize, BufferPool.POOL_SIZE, PoolMaxSize);
        }
 public HttpHandler()
 {
     RequestDispatchs = new BeetleX.Dispatchs.DispatchCenter <HttpToken>(OnRequest, Math.Min(Environment.ProcessorCount, 16));
 }