proxygen
wangle::ManagedConnection Class Referenceabstract

#include <ManagedConnection.h>

Inheritance diagram for wangle::ManagedConnection:
folly::HHWheelTimer::Callback folly::DelayedDestruction folly::DelayedDestructionBase proxygen::HTTPSessionBase TestConnection wangle::AcceptorHandshakeManager wangle::ServerAcceptor< Pipeline >::ServerConnection proxygen::HTTPSession wangle::PeekingAcceptorHandshakeManager proxygen::HTTPDownstreamSession proxygen::HTTPUpstreamSession

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)
 
ConnectionManagergetConnectionManager ()
 
- 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}
 
ConnectionManagerconnectionManager_
 
folly::SafeIntrusiveListHook listHook_
 

Friends

class ConnectionManager
 

Detailed Description

Interface describing a connection that can be managed by a container such as an Acceptor.

Definition at line 32 of file ManagedConnection.h.

Member Enumeration Documentation

Enumerator
NONE 
SENT_NOTIFY_PENDING_SHUTDOWN 
SENT_CLOSE_WHEN_IDLE 

Definition at line 141 of file ManagedConnection.h.

141  {
142  NONE,
143  SENT_NOTIFY_PENDING_SHUTDOWN,
144  SENT_CLOSE_WHEN_IDLE,
145  };

Constructor & Destructor Documentation

wangle::ManagedConnection::ManagedConnection ( )

Definition at line 23 of file ManagedConnection.cpp.

24  : connectionManager_(nullptr) {
25 }
ConnectionManager * connectionManager_
wangle::ManagedConnection::~ManagedConnection ( )
overrideprotected

Definition at line 27 of file ManagedConnection.cpp.

References connectionManager_, and wangle::ConnectionManager::removeConnection().

Referenced by getConnectionManager().

27  {
28  if (connectionManager_) {
30  }
31 }
void removeConnection(ManagedConnection *connection)
ConnectionManager * connectionManager_

Member Function Documentation

virtual void wangle::ManagedConnection::closeWhenIdle ( )
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().

virtual void wangle::ManagedConnection::describe ( std::ostream &  os) const
pure virtual

Print a human-readable description of the connection.

Parameters
osDestination stream.

Implemented in proxygen::HTTPSession, wangle::AcceptorHandshakeManager, wangle::ServerAcceptor< Pipeline >::ServerConnection, and TestConnection.

Referenced by wangle::operator<<().

virtual void wangle::ManagedConnection::dropConnection ( )
pure virtual
virtual void wangle::ManagedConnection::dumpConnectionState ( uint8_t  loglevel)
pure virtual
virtual std::chrono::milliseconds wangle::ManagedConnection::getIdleTime ( ) const
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().

68  {
69  return std::chrono::milliseconds(0);
70  }
virtual bool wangle::ManagedConnection::isBusy ( ) const
pure virtual
virtual void wangle::ManagedConnection::notifyPendingShutdown ( )
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().

void wangle::ManagedConnection::resetTimeout ( )
virtual

If the connection has a connection manager, reset the timeout countdown to connection manager's default timeout.

Note
If the connection manager doesn't have the connection scheduled for a timeout already, this method will schedule one. If the connection manager does have the connection connection scheduled for a timeout, this method will push back the timeout to N msec from now, where N is the connection manager's timer interval.

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().

34  {
35  if (connectionManager_) {
37  }
38 }
std::chrono::milliseconds getDefaultTimeout() const
void resetTimeoutTo(std::chrono::milliseconds)
ConnectionManager * connectionManager_
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().

41  {
42  if (connectionManager_) {
43  connectionManager_->scheduleTimeout(this, timeout);
44  }
45 }
void scheduleTimeout(ManagedConnection *const connection, std::chrono::milliseconds timeout)
ConnectionManager * connectionManager_
void wangle::ManagedConnection::scheduleTimeout ( folly::HHWheelTimer::Callback callback,
std::chrono::milliseconds  timeout 
)
virtual

Definition at line 48 of file ManagedConnection.cpp.

References connectionManager_, and wangle::ConnectionManager::scheduleTimeout().

Referenced by fireCloseWhenIdle().

50  {
51  if (connectionManager_) {
52  connectionManager_->scheduleTimeout(callback, timeout);
53  }
54 }
void scheduleTimeout(ManagedConnection *const connection, std::chrono::milliseconds timeout)
ConnectionManager * connectionManager_
void wangle::ManagedConnection::setConnectionManager ( ConnectionManager mgr)
inlineprivate
void wangle::ManagedConnection::timeoutExpired ( )
overridepure virtualnoexcept

Friends And Related Function Documentation

friend class ConnectionManager
friend

Definition at line 149 of file ManagedConnection.h.

Member Data Documentation

ConnectionManager* wangle::ManagedConnection::connectionManager_
private
folly::SafeIntrusiveListHook wangle::ManagedConnection::listHook_
private

Definition at line 157 of file ManagedConnection.h.

Referenced by wangle::ConnectionManager::addConnection().

DrainState wangle::ManagedConnection::state_ {DrainState::NONE}
private

Definition at line 147 of file ManagedConnection.h.

Referenced by fireCloseWhenIdle(), and fireNotifyPendingShutdown().


The documentation for this class was generated from the following files: