proxygen
|
#include <ManagedConnection.h>
Classes | |
class | Callback |
Public Member Functions | |
ManagedConnection () | |
void | timeoutExpired () noexceptoverride=0 |
virtual void | describe (std::ostream &os) const =0 |
virtual bool | isBusy () const =0 |
virtual std::chrono::milliseconds | getIdleTime () const |
virtual void | notifyPendingShutdown ()=0 |
void | fireNotifyPendingShutdown () |
virtual void | closeWhenIdle ()=0 |
void | fireCloseWhenIdle (bool force_to_close=false) |
virtual void | dropConnection ()=0 |
virtual void | dumpConnectionState (uint8_t loglevel)=0 |
virtual void | resetTimeout () |
void | resetTimeoutTo (std::chrono::milliseconds) |
virtual void | scheduleTimeout (folly::HHWheelTimer::Callback *callback, std::chrono::milliseconds timeout) |
ConnectionManager * | getConnectionManager () |
Public Member Functions inherited from folly::HHWheelTimer::Callback | |
Callback ()=default | |
virtual | ~Callback () |
virtual void | callbackCanceled () noexcept |
void | cancelTimeout () |
bool | isScheduled () const |
std::chrono::milliseconds | getTimeRemaining () |
Public Member Functions inherited from folly::DelayedDestruction | |
virtual void | destroy () |
bool | getDestroyPending () const |
Public Member Functions inherited from folly::DelayedDestructionBase | |
virtual | ~DelayedDestructionBase ()=default |
Protected Member Functions | |
~ManagedConnection () override | |
Protected Member Functions inherited from folly::HHWheelTimer::Callback | |
virtual std::chrono::steady_clock::time_point | getCurTime () |
Protected Member Functions inherited from folly::DelayedDestruction | |
~DelayedDestruction () override=default | |
DelayedDestruction () | |
Protected Member Functions inherited from folly::DelayedDestructionBase | |
DelayedDestructionBase () | |
uint32_t | getDestructorGuardCount () const |
Private Types | |
enum | DrainState { DrainState::NONE, DrainState::SENT_NOTIFY_PENDING_SHUTDOWN, DrainState::SENT_CLOSE_WHEN_IDLE } |
Private Member Functions | |
void | setConnectionManager (ConnectionManager *mgr) |
Private Attributes | |
DrainState | state_ {DrainState::NONE} |
ConnectionManager * | connectionManager_ |
folly::SafeIntrusiveListHook | listHook_ |
Friends | |
class | ConnectionManager |
Interface describing a connection that can be managed by a container such as an Acceptor.
Definition at line 32 of file ManagedConnection.h.
|
strongprivate |
Enumerator | |
---|---|
NONE | |
SENT_NOTIFY_PENDING_SHUTDOWN | |
SENT_CLOSE_WHEN_IDLE |
Definition at line 141 of file ManagedConnection.h.
wangle::ManagedConnection::ManagedConnection | ( | ) |
Definition at line 23 of file ManagedConnection.cpp.
|
overrideprotected |
Definition at line 27 of file ManagedConnection.cpp.
References connectionManager_, and wangle::ConnectionManager::removeConnection().
Referenced by getConnectionManager().
|
pure virtual |
Instruct the connection that it should shutdown as soon as it is safe. This is called after notifyPendingShutdown().
Implemented in proxygen::HTTPSession, wangle::AcceptorHandshakeManager, wangle::ServerAcceptor< Pipeline >::ServerConnection, and TestConnection.
Referenced by fireCloseWhenIdle(), and fireNotifyPendingShutdown().
|
pure virtual |
Print a human-readable description of the connection.
os | Destination stream. |
Implemented in proxygen::HTTPSession, wangle::AcceptorHandshakeManager, wangle::ServerAcceptor< Pipeline >::ServerConnection, and TestConnection.
Referenced by wangle::operator<<().
|
pure virtual |
Forcibly drop a connection.
If a request is in progress, this should cause the connection to be closed with a reset.
Implemented in proxygen::HTTPSession, wangle::AcceptorHandshakeManager, wangle::ServerAcceptor< Pipeline >::ServerConnection, and TestConnection.
Referenced by wangle::ConnectionManager::dropAllConnections(), wangle::ConnectionManager::dropConnections(), wangle::ConnectionManager::dropIdleConnections(), and fireCloseWhenIdle().
|
pure virtual |
Dump the state of the connection to the log
Implemented in proxygen::HTTPSession, wangle::AcceptorHandshakeManager, wangle::ServerAcceptor< Pipeline >::ServerConnection, and TestConnection.
Referenced by wangle::ConnectionManager::dropAllConnections(), and fireCloseWhenIdle().
|
inline |
Definition at line 91 of file ManagedConnection.h.
References closeWhenIdle(), dropConnection(), dumpConnectionState(), resetTimeout(), resetTimeoutTo(), scheduleTimeout(), SENT_CLOSE_WHEN_IDLE, SENT_NOTIFY_PENDING_SHUTDOWN, state_, folly::detail::timeout, and uint8_t.
Referenced by wangle::ConnectionManager::addConnection(), and wangle::ConnectionManager::DrainHelper::drainConnections().
|
inline |
Definition at line 78 of file ManagedConnection.h.
References closeWhenIdle(), NONE, notifyPendingShutdown(), SENT_NOTIFY_PENDING_SHUTDOWN, and state_.
Referenced by wangle::ConnectionManager::addConnection(), and wangle::ConnectionManager::DrainHelper::drainConnections().
|
inline |
Definition at line 133 of file ManagedConnection.h.
References connectionManager_, and ~ManagedConnection().
Referenced by wangle::ConnectionManager::addConnection(), proxygen::HTTPSession::createTransaction(), proxygen::HTTPSession::detach(), proxygen::HTTPUpstreamSession::detachThreadLocals(), and wangle::ConnectionManager::removeConnection().
|
inlinevirtual |
Get the idle time of the connection. If it returning 0, that means the idle connections will never be dropped during pre load shedding stage.
Reimplemented in proxygen::HTTPSessionBase.
Definition at line 68 of file ManagedConnection.h.
References notifyPendingShutdown().
|
pure virtual |
Check whether the connection has any requests outstanding.
Implemented in proxygen::HTTPSession, wangle::AcceptorHandshakeManager, wangle::ServerAcceptor< Pipeline >::ServerConnection, and TestConnection.
Referenced by wangle::ConnectionManager::DrainHelper::drainConnections().
|
pure virtual |
Notify the connection that a shutdown is pending. This method will be called at the beginning of graceful shutdown.
Implemented in proxygen::HTTPSession, wangle::AcceptorHandshakeManager, wangle::ServerAcceptor< Pipeline >::ServerConnection, and TestConnection.
Referenced by fireNotifyPendingShutdown(), and getIdleTime().
|
virtual |
If the connection has a connection manager, reset the timeout countdown to connection manager's default timeout.
Definition at line 34 of file ManagedConnection.cpp.
References connectionManager_, wangle::ConnectionManager::getDefaultTimeout(), and resetTimeoutTo().
Referenced by proxygen::HTTPSession::detach(), fireCloseWhenIdle(), proxygen::HTTPSession::readBufferAvailable(), proxygen::HTTPSession::readDataAvailable(), proxygen::HTTPSession::readTimeoutExpired(), and proxygen::HTTPSession::resumeReadsImpl().
void wangle::ManagedConnection::resetTimeoutTo | ( | std::chrono::milliseconds | timeout | ) |
If the connection has a connection manager, reset the timeout countdown to user specified timeout.
Definition at line 41 of file ManagedConnection.cpp.
References connectionManager_, and wangle::ConnectionManager::scheduleTimeout().
Referenced by fireCloseWhenIdle(), and resetTimeout().
|
virtual |
Definition at line 48 of file ManagedConnection.cpp.
References connectionManager_, and wangle::ConnectionManager::scheduleTimeout().
Referenced by fireCloseWhenIdle().
|
inlineprivate |
Definition at line 151 of file ManagedConnection.h.
References connectionManager_.
Referenced by wangle::ConnectionManager::addConnection(), wangle::ConnectionManager::dropAllConnections(), and wangle::ConnectionManager::removeConnection().
|
overridepure virtualnoexcept |
timeoutExpired() is invoked when the timeout has expired.
Implements folly::HHWheelTimer::Callback.
Implemented in proxygen::HTTPSession, wangle::AcceptorHandshakeManager, wangle::ServerAcceptor< Pipeline >::ServerConnection, and TestConnection.
|
friend |
Definition at line 149 of file ManagedConnection.h.
|
private |
Definition at line 155 of file ManagedConnection.h.
Referenced by getConnectionManager(), resetTimeout(), resetTimeoutTo(), scheduleTimeout(), setConnectionManager(), and ~ManagedConnection().
|
private |
Definition at line 157 of file ManagedConnection.h.
Referenced by wangle::ConnectionManager::addConnection().
|
private |
Definition at line 147 of file ManagedConnection.h.
Referenced by fireCloseWhenIdle(), and fireNotifyPendingShutdown().