2 +----------------------------------------------------------------------+
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"
27 ///////////////////////////////////////////////////////////////////////////////
29 struct SatelliteServerInfo
;
31 struct SatelliteServer
{
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
;}
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;
58 ///////////////////////////////////////////////////////////////////////////////
61 struct SatelliteServerInfo
{
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
;
69 * Check whether a requested path should be allowed on the main server.
71 static bool checkMainURL(const std::string
& path
);
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
;}
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
;}
102 SatelliteServer::Type m_type
;
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_