proxygen
wangle::Pipeline< R, W > Class Template Reference

#include <Pipeline.h>

Inheritance diagram for wangle::Pipeline< R, W >:
wangle::PipelineBase wangle::StaticPipeline< R, W >

Public Types

using Ptr = std::shared_ptr< Pipeline >
 

Public Member Functions

 ~Pipeline () override
 
template<class T = R>
std::enable_if<!std::is_same< T, folly::Unit >::value >::type read (R msg)
 
template<class T = R>
std::enable_if<!std::is_same< T, folly::Unit >::value >::type readEOF ()
 
template<class T = R>
std::enable_if<!std::is_same< T, folly::Unit >::value >::type readException (folly::exception_wrapper e)
 
template<class T = R>
std::enable_if<!std::is_same< T, folly::Unit >::value >::type transportActive ()
 
template<class T = R>
std::enable_if<!std::is_same< T, folly::Unit >::value >::type transportInactive ()
 
template<class T = W>
std::enable_if<!std::is_same< T, folly::Unit >::value, folly::Future< folly::Unit > >::type write (W msg)
 
template<class T = W>
std::enable_if<!std::is_same< T, folly::Unit >::value, folly::Future< folly::Unit > >::type writeException (folly::exception_wrapper e)
 
template<class T = W>
std::enable_if<!std::is_same< T, folly::Unit >::value, folly::Future< folly::Unit > >::type close ()
 
void finalize () override
 
- Public Member Functions inherited from wangle::PipelineBase
virtual ~PipelineBase ()=default
 
void setPipelineManager (PipelineManager *manager)
 
PipelineManagergetPipelineManager ()
 
void deletePipeline ()
 
void setTransport (std::shared_ptr< folly::AsyncTransport > transport)
 
std::shared_ptr< folly::AsyncTransportgetTransport ()
 
void setWriteFlags (folly::WriteFlags flags)
 
folly::WriteFlags getWriteFlags ()
 
void setReadBufferSettings (uint64_t minAvailable, uint64_t allocationSize)
 
std::pair< uint64_t, uint64_tgetReadBufferSettings ()
 
void setTransportInfo (std::shared_ptr< TransportInfo > tInfo)
 
std::shared_ptr< TransportInfogetTransportInfo ()
 
template<class H >
PipelineBaseaddBack (std::shared_ptr< H > handler)
 
template<class H >
PipelineBaseaddBack (H &&handler)
 
template<class H >
PipelineBaseaddBack (H *handler)
 
template<class H >
PipelineBaseaddFront (std::shared_ptr< H > handler)
 
template<class H >
PipelineBaseaddFront (H &&handler)
 
template<class H >
PipelineBaseaddFront (H *handler)
 
template<class H >
PipelineBaseremove (H *handler)
 
template<class H >
PipelineBaseremove ()
 
PipelineBaseremoveFront ()
 
PipelineBaseremoveBack ()
 
template<class H >
H * getHandler (int i)
 
template<class H >
H * getHandler ()
 
template<class H >
ContextType< H >::typegetContext (int i)
 
template<class H >
ContextType< H >::typegetContext ()
 
template<class H >
bool setOwner (H *handler)
 
size_t numHandlers () const
 

Static Public Member Functions

static Ptr create ()
 

Protected Member Functions

 Pipeline ()
 
 Pipeline (bool isStatic)
 
- Protected Member Functions inherited from wangle::PipelineBase
template<class Context >
void addContextFront (Context *ctx)
 
void detachHandlers ()
 

Private Attributes

bool isStatic_ {false}
 
InboundLink< R > * front_ {nullptr}
 
OutboundLink< W > * back_ {nullptr}
 

Additional Inherited Members

- Protected Attributes inherited from wangle::PipelineBase
std::vector< std::shared_ptr< PipelineContext > > ctxs_
 
std::vector< PipelineContext * > inCtxs_
 
std::vector< PipelineContext * > outCtxs_
 

Detailed Description

template<class R, class W = folly::Unit>
class wangle::Pipeline< R, W >

Definition at line 170 of file Pipeline.h.

Member Typedef Documentation

template<class R, class W = folly::Unit>
using wangle::Pipeline< R, W >::Ptr = std::shared_ptr<Pipeline>

Definition at line 172 of file Pipeline.h.

Constructor & Destructor Documentation

template<class R , class W >
wangle::Pipeline< R, W >::~Pipeline ( )
override

Definition at line 32 of file Pipeline-inl.h.

References wangle::PipelineBase::detachHandlers(), and wangle::Pipeline< R, W >::isStatic_.

32  {
33  if (!isStatic_) {
35  }
36 }
template<class R , class W >
wangle::Pipeline< R, W >::Pipeline ( )
protected

Definition at line 24 of file Pipeline-inl.h.

24 : isStatic_(false) {}
template<class R , class W >
wangle::Pipeline< R, W >::Pipeline ( bool  isStatic)
explicitprotected

Definition at line 27 of file Pipeline-inl.h.

References wangle::Pipeline< R, W >::isStatic_.

27  : isStatic_(isStatic) {
28  CHECK(isStatic_);
29 }

Member Function Documentation

template<class R , class W >
template<class T >
std::enable_if<!std::is_same< T, folly::Unit >::value, folly::Future< folly::Unit > >::type wangle::Pipeline< R, W >::close ( )

Definition at line 258 of file Pipeline-inl.h.

References wangle::Pipeline< R, W >::back_, and wangle::OutboundLink< Out >::close().

Referenced by AcceptRoutingHandlerTest::clientConnectAndCleanClose().

258  {
259  if (!back_) {
260  throw std::invalid_argument("close(): no outbound handler in Pipeline");
261  }
262  return back_->close();
263 }
OutboundLink< W > * back_
Definition: Pipeline.h:225
template<class R , class W >
void wangle::Pipeline< R, W >::finalize ( )
overridevirtual

Implements wangle::PipelineBase.

Definition at line 267 of file Pipeline-inl.h.

References wangle::Pipeline< R, W >::back_, wangle::PipelineBase::ctxs_, wangle::Pipeline< R, W >::front_, i, wangle::PipelineBase::inCtxs_, and wangle::PipelineBase::outCtxs_.

Referenced by wangle::StaticPipeline< R, W >::initialize(), and wangle::ClientDispatcherBase< wangle::Pipeline, folly::Req, Resp >::setPipeline().

267  {
268  front_ = nullptr;
269  if (!inCtxs_.empty()) {
270  front_ = dynamic_cast<InboundLink<R>*>(inCtxs_.front());
271  for (size_t i = 0; i < inCtxs_.size() - 1; i++) {
272  inCtxs_[i]->setNextIn(inCtxs_[i+1]);
273  }
274  inCtxs_.back()->setNextIn(nullptr);
275  }
276 
277  back_ = nullptr;
278  if (!outCtxs_.empty()) {
279  back_ = dynamic_cast<OutboundLink<W>*>(outCtxs_.back());
280  for (size_t i = outCtxs_.size() - 1; i > 0; i--) {
281  outCtxs_[i]->setNextOut(outCtxs_[i-1]);
282  }
283  outCtxs_.front()->setNextOut(nullptr);
284  }
285 
286  if (!front_) {
287  detail::logWarningIfNotUnit<R>(
288  "No inbound handler in Pipeline, inbound operations will throw "
289  "std::invalid_argument");
290  }
291  if (!back_) {
292  detail::logWarningIfNotUnit<W>(
293  "No outbound handler in Pipeline, outbound operations will throw "
294  "std::invalid_argument");
295  }
296 
297  for (auto it = ctxs_.rbegin(); it != ctxs_.rend(); it++) {
298  (*it)->attachPipeline();
299  }
300 }
InboundLink< R > * front_
Definition: Pipeline.h:224
std::vector< PipelineContext * > outCtxs_
Definition: Pipeline.h:137
std::vector< std::shared_ptr< PipelineContext > > ctxs_
Definition: Pipeline.h:135
std::vector< PipelineContext * > inCtxs_
Definition: Pipeline.h:136
OutboundLink< W > * back_
Definition: Pipeline.h:225
template<class R, class W >
template<class T >
std::enable_if<!std::is_same< T, folly::Unit >::value >::type wangle::Pipeline< R, W >::read ( msg)

Definition at line 185 of file Pipeline-inl.h.

References wangle::Pipeline< R, W >::front_, wangle::InboundLink< In >::read(), type, and value.

185  {
186  if (!front_) {
187  throw std::invalid_argument("read(): no inbound handler in Pipeline");
188  }
189  front_->read(std::forward<R>(msg));
190 }
InboundLink< R > * front_
Definition: Pipeline.h:224
template<class R , class W >
template<class T >
std::enable_if<!std::is_same< T, folly::Unit >::value >::type wangle::Pipeline< R, W >::readEOF ( )

Definition at line 195 of file Pipeline-inl.h.

References wangle::Pipeline< R, W >::front_, wangle::InboundLink< In >::readEOF(), type, and value.

Referenced by TEST_F().

195  {
196  if (!front_) {
197  throw std::invalid_argument("readEOF(): no inbound handler in Pipeline");
198  }
199  front_->readEOF();
200 }
InboundLink< R > * front_
Definition: Pipeline.h:224
template<class R , class W >
template<class T >
std::enable_if<!std::is_same< T, folly::Unit >::value >::type wangle::Pipeline< R, W >::readException ( folly::exception_wrapper  e)

Definition at line 223 of file Pipeline-inl.h.

References wangle::Pipeline< R, W >::front_, folly::gen::move, wangle::InboundLink< In >::readException(), type, and value.

Referenced by TEST_F().

223  {
224  if (!front_) {
225  throw std::invalid_argument(
226  "readException(): no inbound handler in Pipeline");
227  }
229 }
InboundLink< R > * front_
Definition: Pipeline.h:224
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<class R , class W >
template<class T >
std::enable_if<!std::is_same< T, folly::Unit >::value >::type wangle::Pipeline< R, W >::transportActive ( )
template<class R , class W >
template<class T >
std::enable_if<!std::is_same< T, folly::Unit >::value >::type wangle::Pipeline< R, W >::transportInactive ( )

Definition at line 214 of file Pipeline-inl.h.

References wangle::Pipeline< R, W >::front_, wangle::InboundLink< In >::transportInactive(), type, and value.

Referenced by ProxyFrontendHandler::transportActive().

214  {
215  if (front_) {
217  }
218 }
InboundLink< R > * front_
Definition: Pipeline.h:224
template<class R , class W>
template<class T >
std::enable_if<!std::is_same< T, folly::Unit >::value, folly::Future< folly::Unit > >::type wangle::Pipeline< R, W >::write ( msg)

Definition at line 235 of file Pipeline-inl.h.

References wangle::Pipeline< R, W >::back_, type, value, and wangle::OutboundLink< Out >::write().

Referenced by AcceptRoutingHandlerTest::clientConnectAndWrite(), wangle::SerialClientDispatcher< wangle::Pipeline, folly::Req, Resp >::operator()(), and wangle::PipelinedClientDispatcher< Pipeline, Req, Resp >::operator()().

235  {
236  if (!back_) {
237  throw std::invalid_argument("write(): no outbound handler in Pipeline");
238  }
239  return back_->write(std::forward<W>(msg));
240 }
OutboundLink< W > * back_
Definition: Pipeline.h:225
template<class R , class W >
template<class T >
std::enable_if<!std::is_same< T, folly::Unit >::value, folly::Future< folly::Unit > >::type wangle::Pipeline< R, W >::writeException ( folly::exception_wrapper  e)

Definition at line 246 of file Pipeline-inl.h.

References wangle::Pipeline< R, W >::back_, folly::gen::move, type, value, and wangle::OutboundLink< Out >::writeException().

Referenced by AcceptRoutingHandlerTest::sendClientException(), and TEST_F().

246  {
247  if (!back_) {
248  throw std::invalid_argument(
249  "writeException(): no outbound handler in Pipeline");
250  }
251  return back_->writeException(std::move(e));
252 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
OutboundLink< W > * back_
Definition: Pipeline.h:225

Member Data Documentation

template<class R, class W = folly::Unit>
OutboundLink<W>* wangle::Pipeline< R, W >::back_ {nullptr}
private
template<class R, class W = folly::Unit>
bool wangle::Pipeline< R, W >::isStatic_ {false}
private

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