comment out unused parameters
[hiphop-php.git] / hphp / runtime / server / satellite-server.h
blobc9b5216b8e7763fd3ba73001b8107e0399434e84
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_SATELLITE_SERVER_H_
18 #define incl_HPHP_SATELLITE_SERVER_H_
20 #include "hphp/util/hdf.h"
21 #include "hphp/runtime/base/ini-setting.h"
22 #include "hphp/runtime/server/transport.h"
24 #include <chrono>
26 namespace HPHP {
27 ///////////////////////////////////////////////////////////////////////////////
29 struct SatelliteServerInfo;
31 struct SatelliteServer {
32 enum class Type {
33 Unknown,
35 KindOfInternalPageServer, // handles restricted URLs
36 KindOfRPCServer, // invokes one PHP function and returns JSON
37 KindOfXboxServer, // handles internal xbox tasks
40 void setName(const std::string &name) { m_name = name;}
41 const std::string &getName() const { return m_name;}
43 public:
44 static std::unique_ptr<SatelliteServer>
45 Create(std::shared_ptr<SatelliteServerInfo> info);
47 virtual ~SatelliteServer() {}
49 virtual void start() = 0;
50 virtual void stop() = 0;
51 virtual int getActiveWorker() = 0;
52 virtual int getQueuedJobs() = 0;
54 private:
55 std::string m_name;
58 ///////////////////////////////////////////////////////////////////////////////
59 // helpers
61 struct SatelliteServerInfo {
62 /**
63 * These are regular expressions of URLs that are not allowed on main server.
64 * These are collected from all internal page servers.
66 static std::set<std::string> InternalURLs;
68 /**
69 * Check whether a requested path should be allowed on the main server.
71 static bool checkMainURL(const std::string& path);
73 public:
74 SatelliteServerInfo(const IniSetting::Map& ini, const Hdf& hdf,
75 const std::string& ini_key = "");
77 const std::string &getName() const { return m_name; }
78 SatelliteServer::Type getType() const { return m_type; }
79 int getPort() const { return m_port; }
80 std::string getServerIP() const { return m_serverIP; }
81 int getThreadCount() const { return m_threadCount; }
83 // for all libevent servers
84 std::chrono::seconds getTimeoutSeconds() const { return m_timeoutSeconds;}
86 // only for InternalPageServer
87 const std::set<std::string> &getURLs() const { return m_urls;}
89 // only for RPCServer
90 int getMaxRequest() const { return m_maxRequest;}
91 int getMaxDuration() const { return m_maxDuration;}
92 const std::string &getReqInitFunc() const { return m_reqInitFunc;}
93 const std::string &getReqInitDoc() const { return m_reqInitDoc;}
94 const std::string &getPassword() const { return m_password;}
95 const std::set<std::string> &getPasswords() const { return m_passwords;}
96 bool alwaysReset() const { return m_alwaysReset;}
97 const std::set<std::string> &getFunctions() const { return m_functions; }
98 Transport::Method getMethod() const { return m_method;}
100 protected:
101 std::string m_name;
102 SatelliteServer::Type m_type;
103 int m_port = 0;
104 int m_threadCount = 5;
105 int m_maxRequest = 500;
106 int m_maxDuration = 120;
107 std::string m_serverIP;
108 std::chrono::seconds m_timeoutSeconds;
109 std::set<std::string> m_urls; // url regex patterns
110 std::string m_reqInitFunc;
111 std::string m_reqInitDoc;
112 std::string m_password;
113 std::set<std::string> m_passwords;
114 bool m_alwaysReset = false;
115 std::set<std::string> m_functions;
116 Transport::Method m_method;
119 ///////////////////////////////////////////////////////////////////////////////
122 #endif // incl_HPHP_SATELLITE_SERVER_H_