RTBKit
0.9
Open-source framework to create real-time ad bidding systems.
|
#include <zmq_endpoint.h>
Classes | |
struct | AddressInfo |
Public Types | |
typedef std::function< void(std::vector < zmq::message_t > &&)> | RawMessageHandler |
typedef std::function< void(std::vector < std::string > &&)> | MessageHandler |
typedef std::function< void(std::string bindAddress)> | ConnectionEventHandler |
Public Member Functions | |
ZmqNamedEndpoint (std::shared_ptr< zmq::context_t > context) | |
void | init (std::shared_ptr< ConfigurationService > config, int socketType, const std::string &endpointName) |
void | shutdown () |
std::string | bindTcp (PortRange const &portRange=PortRange(), std::string host="") |
void | bind (const std::string &address) |
void | unbindAll () |
template<typename... Args> | |
void | sendMessage (Args &&...args) |
void | sendMessage (const std::vector< std::string > &message) |
void | sendMessage (std::vector< zmq::message_t > &&message) |
zmq::socket_t & | getSocketUnsafe () const |
virtual void | handleRawMessage (std::vector< zmq::message_t > &&message) |
virtual void | handleMessage (std::vector< std::string > &&message) |
virtual void | handleAcceptEvent (std::string boundAddress) |
virtual void | handleDisconnectEvent (std::string boundAddress) |
virtual void | handleCloseEvent (std::string boundAddress) |
size_t | numBoundAddresses () const |
size_t | numActiveConnections (std::string addr="") const |
Public Attributes | |
RawMessageHandler | rawMessageHandler |
MessageHandler | messageHandler |
ConnectionEventHandler | acceptEventHandler |
ConnectionEventHandler | disconnectEventHandler |
ConnectionEventHandler | closeEventHandler |
An endpoint that exposes a zeromq interface that is passive (bound to one or more listening ports) and is published in a configuration service.
Note that the endpoint may be connected to more than one thing.
Definition at line 461 of file zmq_endpoint.h.
void Datacratic::ZmqNamedEndpoint::bind | ( | const std::string & | address | ) | [inline] |
Bind to the given zeromq uri, but don't publish it.
Definition at line 495 of file zmq_endpoint.h.
std::string Datacratic::ZmqNamedEndpoint::bindTcp | ( | PortRange const & | portRange = PortRange() , |
std::string | host = "" |
||
) |
Bind into a tcp port. If the preferred port is not available, it will scan until it finds one that is.
Returns the uri to connect to.
Definition at line 384 of file zmq_endpoint.cc.
zmq::socket_t& Datacratic::ZmqNamedEndpoint::getSocketUnsafe | ( | ) | const [inline] |
Very unsafe method as it bypasses all thread safety.
Definition at line 546 of file zmq_endpoint.h.
virtual void Datacratic::ZmqNamedEndpoint::handleAcceptEvent | ( | std::string | boundAddress | ) | [inline, virtual] |
Callback for when we accept an incoming connection.
Definition at line 597 of file zmq_endpoint.h.
virtual void Datacratic::ZmqNamedEndpoint::handleCloseEvent | ( | std::string | boundAddress | ) | [inline, virtual] |
Callback for when we are no longer bound to an address.
Definition at line 611 of file zmq_endpoint.h.
virtual void Datacratic::ZmqNamedEndpoint::handleDisconnectEvent | ( | std::string | boundAddress | ) | [inline, virtual] |
Callback for when an incoming connection is closed.
Definition at line 604 of file zmq_endpoint.h.
virtual void Datacratic::ZmqNamedEndpoint::handleRawMessage | ( | std::vector< zmq::message_t > && | message | ) | [inline, virtual] |
Handle a message. The default implementation will call syncMessageHandler if it is defined; otherwise it converts the message to strings and calls handleMessage.
Definition at line 563 of file zmq_endpoint.h.
size_t Datacratic::ZmqNamedEndpoint::numActiveConnections | ( | std::string | addr = "" | ) | const [inline] |
Interrogate the number of connections. If addr is the empty string then it is over all bound addresses.
Definition at line 627 of file zmq_endpoint.h.
size_t Datacratic::ZmqNamedEndpoint::numBoundAddresses | ( | ) | const [inline] |
Interrogates the number of addresses we're bound to.
Definition at line 618 of file zmq_endpoint.h.
void Datacratic::ZmqNamedEndpoint::sendMessage | ( | std::vector< zmq::message_t > && | message | ) | [inline] |
Send a raw message on.
Definition at line 533 of file zmq_endpoint.h.
void Datacratic::ZmqNamedEndpoint::unbindAll | ( | ) | [inline] |
Unbind to all addresses.
Definition at line 507 of file zmq_endpoint.h.
ConnectionEventHandler Datacratic::ZmqNamedEndpoint::acceptEventHandler |
Callback for when we accept an incoming connection.
Definition at line 588 of file zmq_endpoint.h.
ConnectionEventHandler Datacratic::ZmqNamedEndpoint::closeEventHandler |
Callback for when we are no longer bound to an address.
Definition at line 594 of file zmq_endpoint.h.
ConnectionEventHandler Datacratic::ZmqNamedEndpoint::disconnectEventHandler |
Callback for when an incoming connection is closed.
Definition at line 591 of file zmq_endpoint.h.