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

#include <zmq_endpoint.h>

Inheritance diagram for Datacratic::ZmqNamedProxy:
Datacratic::MessageLoop Datacratic::Epoller Datacratic::AsyncEventSource Datacratic::ZmqNamedClientBusProxy

List of all members.

Public Types

typedef std::function< void(std::string)> ConnectionHandler

Public Member Functions

 ZmqNamedProxy (std::shared_ptr< zmq::context_t > context)
void shutdown ()
bool isConnected () const
virtual void onConnect (const std::string &source)
virtual void onDisconnect (const std::string &source)
void init (std::shared_ptr< ConfigurationService > config, int socketType, const std::string &identity="")
bool connect (const std::string &endpointName, ConnectionStyle style=CS_ASYNCHRONOUS)
bool connectToServiceClass (const std::string &serviceClass, const std::string &endpointName, ConnectionStyle style=CS_ASYNCHRONOUS)
bool onConfigChange (ConfigurationService::ChangeType change, const std::string &key, const Json::Value &newValue)
zmq::socket_tsocket () const
ZmqEventSource::SocketLock * socketLock () const
template<typename... Args>
void sendMessage (Args &&...args)
void disconnect ()

Public Attributes

ConnectionHandler connectHandler
ConnectionHandler disconnectHandler

Protected Types

enum  ConnectionType { NO_CONNECTION, CONNECT_DIRECT, CONNECT_TO_CLASS }
enum  ConnectionState { NOT_CONNECTED, CONNECTION_PENDING, CONNECTED }

Protected Member Functions

void onServiceNodeChange (const std::string &path, ConfigurationService::ChangeType change)
void onEndpointNodeChange (const std::string &path, ConfigurationService::ChangeType change)

Protected Attributes

ConfigurationService::Watch serviceWatch
ConfigurationService::Watch endpointWatch
std::shared_ptr
< ConfigurationService
config
std::shared_ptr< zmq::context_tcontext_
std::shared_ptr< zmq::socket_tsocket_
ZmqEventSource::SocketLock socketLock_
enum
Datacratic::ZmqNamedProxy::ConnectionType 
connectionType
enum
Datacratic::ZmqNamedProxy::ConnectionState 
connectionState
std::string serviceClass
 Service class we're connecting to.
std::string endpointName
 Name of endpoint to connect to.
std::string connectedService
 Name of service we're connected to.
std::string connectedUri
 URI we're connected to.

Detailed Description

Proxy to connect to a named zeromq-based service.

Definition at line 864 of file zmq_endpoint.h.


Member Typedef Documentation

typedef std::function<void (std::string)> Datacratic::ZmqNamedProxy::ConnectionHandler

Type of callback for a new connection.

Definition at line 887 of file zmq_endpoint.h.


Member Enumeration Documentation

Enumerator:
NO_CONNECTION 

No connection type yet.

CONNECT_DIRECT 

Connect directly to a named service.

CONNECT_TO_CLASS 

Connect to a service class.

Definition at line 999 of file zmq_endpoint.h.


Member Function Documentation

bool Datacratic::ZmqNamedProxy::connect ( const std::string &  endpointName,
ConnectionStyle  style = CS_ASYNCHRONOUS 
)

Connect to the given endpoint via zeromq. Returns whether the connection could be established.

If synchronous is true, then the method will not return until the connection is really established.

If mustSucceed is true, then an exception will be thrown if the connection cannot be established.

Definition at line 488 of file zmq_endpoint.cc.

bool Datacratic::ZmqNamedProxy::connectToServiceClass ( const std::string &  serviceClass,
const std::string &  endpointName,
ConnectionStyle  style = CS_ASYNCHRONOUS 
)

Connect to one of the endpoints that provides the given service. The endpointName tells which endpoint of the service class that should be connected to.

Looks up the service providers in the configuration service.

Definition at line 572 of file zmq_endpoint.cc.

Disconnect from the parent message loop.

Reimplemented from Datacratic::AsyncEventSource.

Definition at line 974 of file zmq_endpoint.h.

bool Datacratic::ZmqNamedProxy::onConfigChange ( ConfigurationService::ChangeType  change,
const std::string &  key,
const Json::Value newValue 
)

Called back when one of our endpoints either changes or disappears.

virtual void Datacratic::ZmqNamedProxy::onConnect ( const std::string &  source) [inline, virtual]

Function that will be called when we make a new connection to a remote service provider.

Reimplemented in Datacratic::ZmqNamedClientBusProxy.

Definition at line 896 of file zmq_endpoint.h.

virtual void Datacratic::ZmqNamedProxy::onDisconnect ( const std::string &  source) [inline, virtual]

Function that will be called when we lose a connection to a remote service provider.

Reimplemented in Datacratic::ZmqNamedClientBusProxy.

Definition at line 909 of file zmq_endpoint.h.

Get the zeromq socket to listen to.

Definition at line 947 of file zmq_endpoint.h.


Member Data Documentation

Callback that will be called when we get a new connection if onConnect() is not overridden.

Definition at line 891 of file zmq_endpoint.h.

Callback that will be called when we get a disconnection if onDisconnect() is not overridden.

Definition at line 904 of file zmq_endpoint.h.


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