Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the reset() method to HttpAppFramework #1973

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/inc/drogon/HttpAppFramework.h
Original file line number Diff line number Diff line change
Expand Up @@ -1558,6 +1558,7 @@ class DROGON_EXPORT HttpAppFramework : public trantor::NonCopyable
* @brief get the number of active connections.
*/
virtual int64_t getConnectionCount() const = 0;
virtual HttpAppFramework &reset() = 0;

private:
virtual void registerHttpController(
Expand Down
10 changes: 9 additions & 1 deletion lib/src/HttpAppFrameworkImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ HttpAppFrameworkImpl::HttpAppFrameworkImpl()
{
}

HttpAppFramework &HttpAppFrameworkImpl::reset()
{
listenerManagerPtr_ = std::make_unique<ListenerManager>();
pluginsManagerPtr_ = std::make_unique<PluginsManager>();
dbClientManagerPtr_ = std::make_unique<orm::DbClientManager>();
redisClientManagerPtr_ = std::make_unique<nosql::RedisClientManager>();
return *this;
}

static std::function<void()> f = [] {
LOG_TRACE << "Initialize the main event loop in the main thread";
};
Expand Down Expand Up @@ -957,7 +966,6 @@ void HttpAppFrameworkImpl::quit()
listenerManagerPtr_->stopListening();
listenerManagerPtr_.reset();
StaticFileRouter::instance().reset();
HttpControllersRouter::instance().reset();
pluginsManagerPtr_.reset();
redisClientManagerPtr_.reset();
dbClientManagerPtr_.reset();
Expand Down
1 change: 1 addition & 0 deletions lib/src/HttpAppFrameworkImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,7 @@ class HttpAppFrameworkImpl final : public HttpAppFramework
void findSessionForRequest(const HttpRequestImplPtr &req);
HttpResponsePtr handleSessionForResponse(const HttpRequestImplPtr &req,
const HttpResponsePtr &resp);
HttpAppFramework &reset() override;

private:
void registerHttpController(const std::string &pathPattern,
Expand Down
Loading