RTBKit  0.9
Open-source framework to create real-time ad bidding systems.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
Classes | Public Types | Public Member Functions | Public Attributes
Datacratic::RestServiceEndpoint Struct Reference

#include <rest_service_endpoint.h>

Inheritance diagram for Datacratic::RestServiceEndpoint:
Datacratic::MessageLoop Datacratic::Epoller Datacratic::AsyncEventSource EchoService JsonListener MockRestService RTBKIT::AgentConfigurationService RTBKIT::MasterBanker RTBKIT::MonitorEndpoint

List of all members.

Classes

struct  ConnectionId

Public Types

typedef std::function< void(ConnectionId
connection, RestRequest
request)> 
OnHandleRequest
 Request handler function type.

Public Member Functions

 RestServiceEndpoint (std::shared_ptr< zmq::context_t > context)
void shutdown ()
void init (std::shared_ptr< ConfigurationService > config, const std::string &endpointName, double maxAddedLatency=0.005, int numThreads=1)
std::pair< std::string,
std::string > 
bindTcp (PortRange const &zmqRange=PortRange(), PortRange const &httpRange=PortRange(), std::string host="")
std::string bindFixedHttpAddress (std::string host, int port)
std::string bindFixedHttpAddress (std::string address)
virtual void handleRequest (const ConnectionId &connection, const RestRequest &request) const
void doHandleRequest (const ConnectionId &connection, const RestRequest &request)
std::string getHttpRequestId () const

Public Attributes

OnHandleRequest onHandleRequest
ZmqNamedEndpoint zmqEndpoint
HttpNamedEndpoint httpEndpoint
std::function< void(const
ConnectionId &conn, const
RestRequest &req) > 
logRequest
std::function< void(const
ConnectionId &conn, int code,
const std::string &resp, const
std::string &contentType) > 
logResponse

Detailed Description

This class exposes an API for a given service via:

It allows both synchronous and asynchronous responses.

The location of the endpoints are published via a configuration service (usually Zookeeper).

Definition at line 68 of file rest_service_endpoint.h.


Constructor & Destructor Documentation

Datacratic::RestServiceEndpoint::RestServiceEndpoint ( std::shared_ptr< zmq::context_t context) [inline]

Start the service with the given parameters. If the ports are given, then the service will bind to those specific ports for the given endpoints, and so no service discovery will need to be done.

Definition at line 74 of file rest_service_endpoint.h.


Member Function Documentation

std::string Datacratic::RestServiceEndpoint::bindFixedHttpAddress ( std::string  host,
int  port 
) [inline]

Bind to a fixed URI for the HTTP endpoint. This will throw an exception if it can't bind.

example address: "*:4444", "localhost:8888"

Definition at line 358 of file rest_service_endpoint.h.

std::pair<std::string, std::string> Datacratic::RestServiceEndpoint::bindTcp ( PortRange const &  zmqRange = PortRange(),
PortRange const &  httpRange = PortRange(),
std::string  host = "" 
) [inline]

Bind to TCP/IP ports. There is one for zeromq and one for http.

Definition at line 346 of file rest_service_endpoint.h.

virtual void Datacratic::RestServiceEndpoint::handleRequest ( const ConnectionId connection,
const RestRequest request 
) const [inline, virtual]

Handle a request. Default implementation defers to onHandleRequest. Otherwise this method should be overridden.

Reimplemented in JsonListener, and EchoService.

Definition at line 377 of file rest_service_endpoint.h.


The documentation for this struct was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator