proxygen
wangle::ServiceFilter< ReqA, RespA, ReqB, RespB > Class Template Reference

#include <Service.h>

Inheritance diagram for wangle::ServiceFilter< ReqA, RespA, ReqB, RespB >:
wangle::Service< ReqA, RespA >

Public Member Functions

 ServiceFilter (std::shared_ptr< Service< ReqB, RespB >> service)
 
 ~ServiceFilter () override=default
 
folly::Future< folly::Unitclose () override
 
bool isAvailable () override
 
- Public Member Functions inherited from wangle::Service< ReqA, RespA >
virtual folly::Future< RespA > operator() (ReqArequest)=0
 
virtual ~Service ()=default
 

Protected Attributes

std::shared_ptr< Service< ReqB, RespB > > service_
 

Detailed Description

template<typename ReqA, typename RespA, typename ReqB = ReqA, typename RespB = RespA>
class wangle::ServiceFilter< ReqA, RespA, ReqB, RespB >

A Filter acts as a decorator/transformer of a service. It may apply transformations to the input and output of that service:

     class MyService

ReqA -> | | -> ReqB | <- RespB RespA <- |

For example, you may have a service that takes Strings and parses them as Ints. If you want to expose this as a Network Service via Thrift, it is nice to isolate the protocol handling from the business rules. Hence you might have a Filter that converts back and forth between Thrift structs:

[ThriftIn -> (String -> Int) -> ThriftOut]

Definition at line 67 of file Service.h.

Constructor & Destructor Documentation

template<typename ReqA, typename RespA, typename ReqB = ReqA, typename RespB = RespA>
wangle::ServiceFilter< ReqA, RespA, ReqB, RespB >::ServiceFilter ( std::shared_ptr< Service< ReqB, RespB >>  service)
inlineexplicit

Definition at line 69 of file Service.h.

70  : service_(service) {}
std::shared_ptr< Service< ReqB, RespB > > service_
Definition: Service.h:82
template<typename ReqA, typename RespA, typename ReqB = ReqA, typename RespB = RespA>
wangle::ServiceFilter< ReqA, RespA, ReqB, RespB >::~ServiceFilter ( )
overridedefault

Member Function Documentation

template<typename ReqA, typename RespA, typename ReqB = ReqA, typename RespB = RespA>
folly::Future<folly::Unit> wangle::ServiceFilter< ReqA, RespA, ReqB, RespB >::close ( )
inlineoverridevirtual

Reimplemented from wangle::Service< ReqA, RespA >.

Definition at line 73 of file Service.h.

73  {
74  return service_->close();
75  }
std::shared_ptr< Service< ReqB, RespB > > service_
Definition: Service.h:82
template<typename ReqA, typename RespA, typename ReqB = ReqA, typename RespB = RespA>
bool wangle::ServiceFilter< ReqA, RespA, ReqB, RespB >::isAvailable ( )
inlineoverridevirtual

Reimplemented from wangle::Service< ReqA, RespA >.

Definition at line 77 of file Service.h.

77  {
78  return service_->isAvailable();
79  }
std::shared_ptr< Service< ReqB, RespB > > service_
Definition: Service.h:82

Member Data Documentation

template<typename ReqA, typename RespA, typename ReqB = ReqA, typename RespB = RespA>
std::shared_ptr<Service<ReqB, RespB> > wangle::ServiceFilter< ReqA, RespA, ReqB, RespB >::service_
protected

Definition at line 82 of file Service.h.


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