Apache Mesos
Classes | Public Member Functions | Protected Types | Protected Member Functions | Friends | List of all members
mesos::internal::HttpConnectionProcess< Call, Event > Class Template Reference

HTTP connection handler. More...

#include <resource_provider.hpp>

Inheritance diagram for mesos::internal::HttpConnectionProcess< Call, Event >:
process::Process< HttpConnectionProcess< Call, Event > > process::ProcessBase process::EventConsumer

Public Member Functions

 HttpConnectionProcess (const std::string &prefix, process::Owned< EndpointDetector > _detector, ContentType _contentType, const Option< std::string > &_token, const std::function< Option< Error >(const Call &)> &validate, const std::function< void(void)> &connected, const std::function< void(void)> &disconnected, const std::function< void(const std::queue< Event > &)> &received)
 Construct a HTTP connection process. More...
 
process::Future< Nothingsend (const Call &call)
 
void start ()
 
- Public Member Functions inherited from process::Process< HttpConnectionProcess< Call, Event > >
 ~Process () override
 
PID< HttpConnectionProcess< Call, Event > > self () const
 Returns the PID of the process. More...
 
- Public Member Functions inherited from process::ProcessBase
 ProcessBase (const std::string &id="")
 
 ~ProcessBase () override
 
const UPIDself () const
 
- Public Member Functions inherited from process::EventConsumer
virtual ~EventConsumer ()
 

Protected Types

typedef HttpConnectionProcess< Call, Event > Self
 
- Protected Types inherited from process::Process< HttpConnectionProcess< Call, Event > >
typedef HttpConnectionProcess< Call, EventSelf
 
typedef HttpConnectionProcess< Call, EventThis
 
- Protected Types inherited from process::ProcessBase
enum  RemoteConnection { RemoteConnection::REUSE, RemoteConnection::RECONNECT }
 Describes the behavior of the link call when the target pid points to a remote process. More...
 
typedef lambda::function< void(const UPID &, const std::string &)> MessageHandler
 Any function which takes a "from" UPID and a message body as arguments. More...
 
typedef lambda::function< Future< http::Response >const http::Request &)> HttpRequestHandler
 Any function which takes a process::http::Request and returns a process::http::Response. More...
 
typedef lambda::function< Future< http::Response > const http::Request &, const Option< http::authentication::Principal > &)> AuthenticatedHttpRequestHandler
 Any function which takes a process::http::Request and an Option<Principal> and returns a process::http::Response. More...
 

Protected Member Functions

void finalize () override
 Invoked when a process is terminated. More...
 
void detected (const process::Future< Option< process::http::URL >> &future)
 
void connect (const id::UUID &_connectionId)
 
void connected (const id::UUID &_connectionId, const process::Future< std::tuple< process::http::Connection, process::http::Connection >> &_connections)
 
void disconnect ()
 
void disconnected (const id::UUID &_connectionId, const std::string &failure)
 
process::Future< Nothing_send (const id::UUID &_connectionId, const Call &call, const process::http::Response &response)
 
void read ()
 
void _read (const process::http::Pipe::Reader &reader, const process::Future< Result< Event >> &event)
 
void receive (const Event &event)
 
- Protected Member Functions inherited from process::ProcessBase
virtual void serve (Event &&event)
 Invoked when an event is serviced. More...
 
void consume (MessageEvent &&event) override
 
void consume (DispatchEvent &&event) override
 
void consume (HttpEvent &&event) override
 
void consume (ExitedEvent &&event) override
 
void consume (TerminateEvent &&event) override
 
virtual void initialize ()
 Invoked when a process gets spawned. More...
 
virtual void exited (const UPID &)
 Invoked when a linked process has exited. More...
 
virtual void lost (const UPID &)
 Invoked when a linked process can no longer be monitored. More...
 
void send (const UPID &to, const std::string &name, const char *data=nullptr, size_t length=0)
 Sends the message to the specified UPID. More...
 
void send (const UPID &to, std::string &&name)
 
void send (const UPID &to, std::string &&name, std::string &&data)
 
UPID link (const UPID &pid, const RemoteConnection remote=RemoteConnection::REUSE)
 Links with the specified UPID. More...
 
void install (const std::string &name, const MessageHandler &handler)
 Sets up a handler for messages with the specified name. More...
 
template<typename T >
void install (const std::string &name, void(T::*method)(const UPID &, const std::string &))
 Sets up a handler for messages with the specified name. More...
 
void delegate (const std::string &name, const UPID &pid)
 Delegates incoming messages, with the specified name, to the UPID. More...
 
void route (const std::string &name, const Option< std::string > &help, const HttpRequestHandler &handler, const RouteOptions &options=RouteOptions())
 Sets up a handler for HTTP requests with the specified name. More...
 
template<typename T >
void route (const std::string &name, const Option< std::string > &help, Future< http::Response >(T::*method)(const http::Request &), const RouteOptions &options=RouteOptions())
 Sets up a handler for HTTP requests with the specified name. More...
 
void route (const std::string &name, const std::string &realm, const Option< std::string > &help, const AuthenticatedHttpRequestHandler &handler, const RouteOptions &options=RouteOptions())
 
template<typename T >
void route (const std::string &name, const Option< std::string > &realm, const Option< std::string > &help, Future< http::Response >(T::*method)(const http::Request &, const Option< http::authentication::Principal > &), const RouteOptions &options=RouteOptions())
 Forwards to the correct overload of process::ProcessBase::route(), depending on whether the authentication realm realm is present. More...
 
void provide (const std::string &name, const std::string &path, const std::map< std::string, std::string > &types=mime::types)
 Sets up the default HTTP request handler to provide the static asset(s) at the specified absolute path for the specified name. More...
 
template<typename T >
size_t eventCount ()
 Returns the number of events of the given type currently on the event queue. More...
 

Friends

std::ostream & operator<< (std::ostream &stream, State state)
 

Detailed Description

template<typename Call, typename Event>
class mesos::internal::HttpConnectionProcess< Call, Event >

HTTP connection handler.

Manages the connection to a Call/Event based v1 API like the resource provider API.

Member Typedef Documentation

template<typename Call , typename Event >
typedef HttpConnectionProcess<Call, Event> mesos::internal::HttpConnectionProcess< Call, Event >::Self
protected

Constructor & Destructor Documentation

template<typename Call , typename Event >
mesos::internal::HttpConnectionProcess< Call, Event >::HttpConnectionProcess ( const std::string &  prefix,
process::Owned< EndpointDetector _detector,
ContentType  _contentType,
const Option< std::string > &  _token,
const std::function< Option< Error >(const Call &)> &  validate,
const std::function< void(void)> &  connected,
const std::function< void(void)> &  disconnected,
const std::function< void(const std::queue< Event > &)> &  received 
)
inline

Construct a HTTP connection process.

Parameters
prefixprefix of the actor.
_detectorthe endpoint detector.
_contentTypethe content type expected by this connection.
validatea callback which will be invoked when a call needs to be validated.
connecteda callback which will be invoked when the connection is established.
disconnecteda callback which will be invoked when the connection is disconnected.
receiveda callback which will be be invoked when events are received.

Member Function Documentation

template<typename Call , typename Event >
void mesos::internal::HttpConnectionProcess< Call, Event >::_read ( const process::http::Pipe::Reader reader,
const process::Future< Result< Event >> &  event 
)
inlineprotected
template<typename Call , typename Event >
process::Future<Nothing> mesos::internal::HttpConnectionProcess< Call, Event >::_send ( const id::UUID _connectionId,
const Call &  call,
const process::http::Response response 
)
inlineprotected
template<typename Call , typename Event >
void mesos::internal::HttpConnectionProcess< Call, Event >::connect ( const id::UUID _connectionId)
inlineprotected
template<typename Call , typename Event >
void mesos::internal::HttpConnectionProcess< Call, Event >::connected ( const id::UUID _connectionId,
const process::Future< std::tuple< process::http::Connection, process::http::Connection >> &  _connections 
)
inlineprotected
template<typename Call , typename Event >
void mesos::internal::HttpConnectionProcess< Call, Event >::detected ( const process::Future< Option< process::http::URL >> &  future)
inlineprotected
template<typename Call , typename Event >
void mesos::internal::HttpConnectionProcess< Call, Event >::disconnect ( )
inlineprotected
template<typename Call , typename Event >
void mesos::internal::HttpConnectionProcess< Call, Event >::disconnected ( const id::UUID _connectionId,
const std::string &  failure 
)
inlineprotected
template<typename Call , typename Event >
void mesos::internal::HttpConnectionProcess< Call, Event >::finalize ( )
inlineoverrideprotectedvirtual

Invoked when a process is terminated.

NOTE: this does not get invoked automatically if process::ProcessBase::consume(TerminateEvent&&) is overridden.

Reimplemented from process::ProcessBase.

template<typename Call , typename Event >
void mesos::internal::HttpConnectionProcess< Call, Event >::read ( )
inlineprotected
template<typename Call , typename Event >
void mesos::internal::HttpConnectionProcess< Call, Event >::receive ( const Event &  event)
inlineprotected
template<typename Call , typename Event >
process::Future<Nothing> mesos::internal::HttpConnectionProcess< Call, Event >::send ( const Call &  call)
inline
template<typename Call , typename Event >
void mesos::internal::HttpConnectionProcess< Call, Event >::start ( )
inline

Friends And Related Function Documentation

template<typename Call , typename Event >
std::ostream& operator<< ( std::ostream &  stream,
State  state 
)
friend

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