libtasks Documentation  1.6
tasks::net::uwsgi_thrift_async_handler< thrift_result_type, thrift_args_type > Class Template Referenceabstract

#include <uwsgi_thrift_async_handler.h>

Inheritance diagram for tasks::net::uwsgi_thrift_async_handler< thrift_result_type, thrift_args_type >:
Collaboration diagram for tasks::net::uwsgi_thrift_async_handler< thrift_result_type, thrift_args_type >:

Public Types

using handler_finish_func_t = std::function< void()>
 
using result_t = thrift_result_type
 
using args_t = thrift_args_type
 

Public Member Functions

virtual ~uwsgi_thrift_async_handler ()
 
virtual void service (std::shared_ptr< args_t > args)=0
 
virtual std::string service_name () const =0
 
result_tresult_base ()
 Return a reference to the thrift result base object. More...
 
auto result () -> decltype((m_result.success))
 Return a reference to the thrift result object. A thrift handler uses this to return data. More...
 
void set_uwsgi_task (uwsgi_task *t)
 The uwsgi_thrift_async_processor uses this method to assign the underlying uwsgi_task object. More...
 
void on_finish (handler_finish_func_t f)
 
- Public Member Functions inherited from tasks::error_base
 error_base ()
 
virtual ~error_base ()
 
bool error () const
 Return true if an error occured. More...
 
tasks_error error_code () const
 Return the error code. More...
 
const std::string & error_message () const
 Return the error message. More...
 
int sys_errno () const
 Return the errno if available. More...
 
std::string sys_errno_str () const
 Return the errno description if available. More...
 
const tasks_exceptionexception () const
 Return the underlying exception object. More...
 
void set_exception (tasks_exception &e)
 Set an exception to report an error. More...
 
void reset_error ()
 Reset the error state. More...
 

Protected Member Functions

const uwsgi_requestrequest () const
 
const uwsgi_requestrequest_p () const
 
http_responseresponse ()
 
http_responseresponse_p ()
 
void finish ()
 Async handlers call this method to trigger the processor callback. More...
 
void set_error (std::string msg)
 Report an error. More...
 

Private Attributes

result_t m_result
 
uwsgi_taskm_uwsgi_task = nullptr
 
handler_finish_func_t m_finish_func
 

Detailed Description

template<class thrift_result_type, class thrift_args_type>
class tasks::net::uwsgi_thrift_async_handler< thrift_result_type, thrift_args_type >

The base class for asynchronous thrift handlers. The two template arguments have to match the thrift generated types. A handler also has to implement a service and a service_name method. See below.

Definition at line 23 of file uwsgi_thrift_async_handler.h.

Member Typedef Documentation

template<class thrift_result_type, class thrift_args_type>
using tasks::net::uwsgi_thrift_async_handler< thrift_result_type, thrift_args_type >::args_t = thrift_args_type

Definition at line 27 of file uwsgi_thrift_async_handler.h.

template<class thrift_result_type, class thrift_args_type>
using tasks::net::uwsgi_thrift_async_handler< thrift_result_type, thrift_args_type >::handler_finish_func_t = std::function<void()>

Definition at line 25 of file uwsgi_thrift_async_handler.h.

template<class thrift_result_type, class thrift_args_type>
using tasks::net::uwsgi_thrift_async_handler< thrift_result_type, thrift_args_type >::result_t = thrift_result_type

Definition at line 26 of file uwsgi_thrift_async_handler.h.

Constructor & Destructor Documentation

template<class thrift_result_type, class thrift_args_type>
virtual tasks::net::uwsgi_thrift_async_handler< thrift_result_type, thrift_args_type >::~uwsgi_thrift_async_handler ( )
inlinevirtual

Definition at line 57 of file uwsgi_thrift_async_handler.h.

Member Function Documentation

template<class thrift_result_type, class thrift_args_type>
void tasks::net::uwsgi_thrift_async_handler< thrift_result_type, thrift_args_type >::finish ( )
inlineprotected

Async handlers call this method to trigger the processor callback.

Definition at line 48 of file uwsgi_thrift_async_handler.h.

template<class thrift_result_type, class thrift_args_type>
void tasks::net::uwsgi_thrift_async_handler< thrift_result_type, thrift_args_type >::on_finish ( handler_finish_func_t  f)
inline

Set a finish callback. This is used by the uwsgi_thrift_async_processor to get notified when an async operation has finished and the thrift result set can be send back to the caller.

Parameters
fThe callback function

Definition at line 81 of file uwsgi_thrift_async_handler.h.

template<class thrift_result_type, class thrift_args_type>
const uwsgi_request& tasks::net::uwsgi_thrift_async_handler< thrift_result_type, thrift_args_type >::request ( ) const
inlineprotected
Returns
A reference to the underlying request object.

Definition at line 36 of file uwsgi_thrift_async_handler.h.

template<class thrift_result_type, class thrift_args_type>
const uwsgi_request* tasks::net::uwsgi_thrift_async_handler< thrift_result_type, thrift_args_type >::request_p ( ) const
inlineprotected
Returns
A pointer to the underlying request onject.

Definition at line 39 of file uwsgi_thrift_async_handler.h.

template<class thrift_result_type, class thrift_args_type>
http_response& tasks::net::uwsgi_thrift_async_handler< thrift_result_type, thrift_args_type >::response ( )
inlineprotected
Returns
A reference to the underlying response object.

Definition at line 42 of file uwsgi_thrift_async_handler.h.

template<class thrift_result_type, class thrift_args_type>
http_response* tasks::net::uwsgi_thrift_async_handler< thrift_result_type, thrift_args_type >::response_p ( )
inlineprotected
Returns
A pointer to the underlying response onject.

Definition at line 45 of file uwsgi_thrift_async_handler.h.

template<class thrift_result_type, class thrift_args_type>
auto tasks::net::uwsgi_thrift_async_handler< thrift_result_type, thrift_args_type >::result ( ) -> decltype((m_result.success))
inline

Return a reference to the thrift result object. A thrift handler uses this to return data.

Definition at line 72 of file uwsgi_thrift_async_handler.h.

template<class thrift_result_type, class thrift_args_type>
result_t& tasks::net::uwsgi_thrift_async_handler< thrift_result_type, thrift_args_type >::result_base ( )
inline

Return a reference to the thrift result base object.

Definition at line 69 of file uwsgi_thrift_async_handler.h.

template<class thrift_result_type, class thrift_args_type>
virtual void tasks::net::uwsgi_thrift_async_handler< thrift_result_type, thrift_args_type >::service ( std::shared_ptr< args_t args)
pure virtual

The service method will be called by the processor after a new thrift message has been deserialized.

Parameters
argsA pointer to the arguments of the thrift service method.

Implemented in ip_service_async2, and ip_service_async1.

template<class thrift_result_type, class thrift_args_type>
virtual std::string tasks::net::uwsgi_thrift_async_handler< thrift_result_type, thrift_args_type >::service_name ( ) const
pure virtual
Returns
The name of the thrift service. This name has to match the name in the thrift IDL. Look at the uwsgi async test for an example.

Implemented in ip_service_async2, and ip_service_async1.

template<class thrift_result_type, class thrift_args_type>
void tasks::net::uwsgi_thrift_async_handler< thrift_result_type, thrift_args_type >::set_error ( std::string  msg)
inlineprotected

Report an error.

Definition at line 51 of file uwsgi_thrift_async_handler.h.

template<class thrift_result_type, class thrift_args_type>
void tasks::net::uwsgi_thrift_async_handler< thrift_result_type, thrift_args_type >::set_uwsgi_task ( uwsgi_task t)
inline

The uwsgi_thrift_async_processor uses this method to assign the underlying uwsgi_task object.

Definition at line 75 of file uwsgi_thrift_async_handler.h.

Member Data Documentation

template<class thrift_result_type, class thrift_args_type>
handler_finish_func_t tasks::net::uwsgi_thrift_async_handler< thrift_result_type, thrift_args_type >::m_finish_func
private

Definition at line 32 of file uwsgi_thrift_async_handler.h.

template<class thrift_result_type, class thrift_args_type>
result_t tasks::net::uwsgi_thrift_async_handler< thrift_result_type, thrift_args_type >::m_result
private

Definition at line 30 of file uwsgi_thrift_async_handler.h.

template<class thrift_result_type, class thrift_args_type>
uwsgi_task* tasks::net::uwsgi_thrift_async_handler< thrift_result_type, thrift_args_type >::m_uwsgi_task = nullptr
private

Definition at line 31 of file uwsgi_thrift_async_handler.h.


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