proxygen
wangle::ClientBootstrap< Pipeline > Class Template Reference

#include <ClientBootstrap.h>

Inheritance diagram for wangle::ClientBootstrap< Pipeline >:
wangle::BaseClientBootstrap< Pipeline > folly::DestructorCheck

Classes

class  ConnectCallback
 

Public Member Functions

 ClientBootstrap ()
 
ClientBootstrapgroup (std::shared_ptr< folly::IOThreadPoolExecutor > group)
 
ClientBootstrapbind (int port)
 
folly::Future< Pipeline * > connect (const folly::SocketAddress &address, std::chrono::milliseconds timeout=std::chrono::milliseconds(0)) override
 
 ~ClientBootstrap () override=default
 
- Public Member Functions inherited from wangle::BaseClientBootstrap< Pipeline >
 BaseClientBootstrap ()
 
virtual ~BaseClientBootstrap ()=default
 
BaseClientBootstrap< Pipeline > * pipelineFactory (std::shared_ptr< PipelineFactory< Pipeline >> factory) noexcept
 
PipelinegetPipeline ()
 
BaseClientBootstrapsslContext (folly::SSLContextPtr sslContext)
 
BaseClientBootstrapsslSession (SSL_SESSION *sslSession)
 
BaseClientBootstrapserverName (const std::string &sni)
 
BaseClientBootstrapsslSessionEstablishedCallback (SSLSessionEstablishedCallbackUniquePtr sslSessionEstablishedCallback)
 
BaseClientBootstrapdeferSecurityNegotiation (bool deferSecurityNegotiation)
 
void setPipeline (const typename Pipeline::Ptr &pipeline)
 
virtual void makePipeline (std::shared_ptr< folly::AsyncTransportWrapper > socket)
 
- Public Member Functions inherited from folly::DestructorCheck
virtual ~DestructorCheck ()
 

Protected Attributes

int port_
 
std::shared_ptr< folly::IOThreadPoolExecutorgroup_
 
- Protected Attributes inherited from wangle::BaseClientBootstrap< Pipeline >
std::shared_ptr< PipelineFactory< Pipeline > > pipelineFactory_
 
Pipeline::Ptr pipeline_
 
folly::SSLContextPtr sslContext_
 
SSL_SESSION * sslSession_
 
std::string sni_
 
bool deferSecurityNegotiation_
 
SSLSessionEstablishedCallbackUniquePtr sslSessionEstablishedCallback_
 

Additional Inherited Members

- Public Types inherited from wangle::BaseClientBootstrap< Pipeline >
using Ptr = std::unique_ptr< BaseClientBootstrap >
 

Detailed Description

template<typename Pipeline>
class wangle::ClientBootstrap< Pipeline >

Definition at line 35 of file ClientBootstrap.h.

Constructor & Destructor Documentation

template<typename Pipeline>
wangle::ClientBootstrap< Pipeline >::ClientBootstrap ( )
inline

Definition at line 85 of file ClientBootstrap.h.

85  {
86  }
template<typename Pipeline>
wangle::ClientBootstrap< Pipeline >::~ClientBootstrap ( )
overridedefault

Member Function Documentation

template<typename Pipeline>
ClientBootstrap* wangle::ClientBootstrap< Pipeline >::bind ( int  port)
inline

Definition at line 94 of file ClientBootstrap.h.

94  {
95  port_ = port;
96  return this;
97  }
template<typename Pipeline>
folly::Future<Pipeline*> wangle::ClientBootstrap< Pipeline >::connect ( const folly::SocketAddress address,
std::chrono::milliseconds  timeout = std::chrono::milliseconds(0) 
)
inlineoverridevirtual

Implements wangle::BaseClientBootstrap< Pipeline >.

Definition at line 99 of file ClientBootstrap.h.

Referenced by main(), and TEST().

102  {
103  auto base = (group_)
104  ? group_->getEventBase()
106  folly::Future<Pipeline*> retval((Pipeline*)nullptr);
107  base->runImmediatelyOrRunInEventBaseThreadAndWait([&](){
108  std::shared_ptr<folly::AsyncSocket> socket;
109  if (this->sslContext_) {
110  auto sslSocket = folly::AsyncSSLSocket::newSocket(
111  this->sslContext_, base, this->deferSecurityNegotiation_);
112  if (!this->sni_.empty()) {
113  sslSocket->setServerName(this->sni_);
114  }
115  if (this->sslSession_) {
116  sslSocket->setSSLSession(this->sslSession_, true);
117  }
118  socket = sslSocket;
119  } else {
120  socket = folly::AsyncSocket::newSocket(base);
121  }
123  retval = promise.getFuture();
124  socket->connect(
125  new ConnectCallback(
126  std::move(promise),
127  this,
128  socket,
130  address,
131  timeout.count());
132  });
133  return retval;
134  }
EventBase * getEventBase() const
std::shared_ptr< folly::IOThreadPoolExecutor > group_
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
static EventBaseManager * get()
static std::shared_ptr< AsyncSSLSocket > newSocket(const std::shared_ptr< folly::SSLContext > &ctx, EventBase *evb, int fd, bool server=true, bool deferSecurityNegotiation=false)
Future< T > getFuture()
Definition: Promise-inl.h:97
NetworkSocket socket(int af, int type, int protocol)
Definition: NetOps.cpp:412
static std::shared_ptr< AsyncSocket > newSocket(EventBase *evb)
Definition: AsyncSocket.h:281
SSLSessionEstablishedCallbackUniquePtr sslSessionEstablishedCallback_
template<typename Pipeline>
ClientBootstrap* wangle::ClientBootstrap< Pipeline >::group ( std::shared_ptr< folly::IOThreadPoolExecutor group)
inline

Definition at line 88 of file ClientBootstrap.h.

Referenced by wangle::ClientBootstrap< DefaultPipeline >::group(), and main().

89  {
90  group_ = group;
91  return this;
92  }
std::shared_ptr< folly::IOThreadPoolExecutor > group_
ClientBootstrap * group(std::shared_ptr< folly::IOThreadPoolExecutor > group)

Member Data Documentation

template<typename Pipeline>
std::shared_ptr<folly::IOThreadPoolExecutor> wangle::ClientBootstrap< Pipeline >::group_
protected
template<typename Pipeline>
int wangle::ClientBootstrap< Pipeline >::port_
protected

Definition at line 139 of file ClientBootstrap.h.

Referenced by wangle::ClientBootstrap< DefaultPipeline >::bind().


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