34 std::shared_ptr<HTTPCodecFactory> codecFactory,
43 auto acc = std::shared_ptr<HTTPServerAcceptor>(
48 acc->init(
nullptr, eventBase);
66 std::make_unique<RejectConnectFilterFactory>());
71 if (
options_->enableContentCompression) {
74 std::make_unique<ZlibServerFilterFactory>(
76 options_->contentCompressionMinimumSize,
99 CHECK(evb) <<
"Invariant violated - started thread must have an EventBase";
100 evb->runInEventBaseThread([=](){
101 for (
auto& factory:
options_->handlerFactories) {
102 factory->onServerStart(evb);
108 for (
auto& factory:
options_->handlerFactories) {
109 factory->onServerStop();
120 std::function<
void(std::exception_ptr)> onError) {
123 auto accExe = std::make_shared<IOThreadPoolExecutor>(1);
124 auto exe = std::make_shared<IOThreadPoolExecutor>(
options_->threads,
125 std::make_shared<folly::NamedThreadFactory>(
"HTTPSrvExec"));
126 auto exeObserver = std::make_shared<HandlerCallbacks>(
options_);
128 exe->addObserver(exeObserver);
134 auto factory = std::make_shared<AcceptorFactory>(
142 if (accConfig.enableTCPFastOpen) {
147 bootstrap_[
i].socketConfig.enableTCPFastOpen =
true;
149 accConfig.fastOpenQueueSize;
152 if (options_->preboundSockets_.size() > 0) {
158 }
catch (
const std::exception& ex) {
162 onError(std::current_exception());
170 if (!
options_->shutdownOn.empty()) {
210 const std::vector<const folly::AsyncSocketBase*>
213 std::vector<const folly::AsyncSocketBase*> sockets;
215 auto& bootstrapSockets =
bootstrap_[
i].getSockets();
217 sockets.push_back(bootstrapSockets[j].
get());
229 auto& bootstrapSockets =
bootstrap_[0].getSockets();
230 if (bootstrapSockets.size() == 0) {
237 if (socketFds.size() == 0) {
248 if (!acceptor || !acceptor->
isSSL()) {
265 if (!acceptor || !acceptor->
isSSL()) {
std::vector< std::string > newSeeds
static AcceptorConfiguration makeConfig(const HTTPServer::IPConfig &ipConfig, const HTTPServerOptions &opts)
std::vector< std::string > currentSeeds
void threadStarted(ThreadPoolExecutor::ThreadHandle *h) override
AcceptorFactory(std::shared_ptr< HTTPServerOptions > options, std::shared_ptr< HTTPCodecFactory > codecFactory, AcceptorConfiguration config, HTTPSession::InfoCallback *sessionInfoCb)
void start(std::function< void()> onSuccess=nullptr, std::function< void(std::exception_ptr)> onError=nullptr)
std::vector< int > getSockets() const
virtual void setTLSTicketSecrets(const std::vector< std::string > &oldSecrets, const std::vector< std::string > ¤tSecrets, const std::vector< std::string > &newSecrets)
constexpr detail::Map< Move > move
EventBase * getEventBase()
void bind(std::vector< IPConfig > &&addrs)
std::shared_ptr< HTTPServerOptions > options_
int getListenSocket() const
#define FOR_EACH_RANGE(i, begin, end)
void runInLoop(LoopCallback *callback, bool thisIteration=false)
std::shared_ptr< wangle::Acceptor > newAcceptor(folly::EventBase *eventBase) override
void updateTLSCredentials()
HandlerCallbacks(std::shared_ptr< HTTPServerOptions > options)
AcceptorConfiguration config_
bool runInEventBaseThread(void(*fn)(T *), T *arg)
void threadStopped(ThreadPoolExecutor::ThreadHandle *h) override
std::shared_ptr< HTTPCodecFactory > codecFactory_
std::shared_ptr< HTTPServerOptions > options_
std::vector< IPConfig > addresses_
std::unique_ptr< SignalHandler > signalHandler_
HTTPSession::InfoCallback * sessionInfoCb_
folly::EventBase * mainEventBase_
HTTPSession::InfoCallback * sessionInfoCb_
std::shared_ptr< HTTPServerOptions > options_
static std::unique_ptr< HTTPServerAcceptor > make(const AcceptorConfiguration &conf, const HTTPServerOptions &opts, const std::shared_ptr< HTTPCodecFactory > &codecFactory=nullptr)
void updateTicketSeeds(wangle::TLSTicketKeySeeds seeds)
std::vector< std::string > oldSeeds
std::vector< wangle::ServerBootstrap< wangle::DefaultPipeline > > bootstrap_
HTTPServer(HTTPServerOptions options)
PUSHMI_INLINE_VAR constexpr detail::get_fn< T > get
virtual void resetSSLContextConfigs()
virtual folly::EventBase * getEventBase() const
const std::vector< const folly::AsyncSocketBase * > getSockets() const