BlueZero (BØ)
Middleware for distributed applications
|
The service client class. More...
#include <b0/service_client.h>
Public Member Functions | |
ServiceClient (Node *node, std::string service_name, bool managed=true, bool notify_graph=true) | |
Construct an ServiceClient child of the specified Node. | |
virtual | ~ServiceClient () |
ServiceClient destructor. | |
void | log (LogLevel level, std::string message) const override |
Log a message using node's logger, prepending this service client informations. | |
virtual void | init () override |
Perform initialization and optionally send graph notify. | |
virtual void | cleanup () override |
Perform cleanup and optionally send graph notify. | |
std::string | getServiceName () |
Return the name of this client's service. | |
virtual void | call (const std::string &req, std::string &rep) |
Write a request and read a reply from the underlying ZeroMQ REQ socket. More... | |
Public Member Functions inherited from b0::Socket | |
Socket (Node *node, int type, std::string name, bool managed=true) | |
Construct a Socket. | |
virtual | ~Socket () |
Socket destructor. | |
void | setHasHeader (bool has_header) |
Set the has_header_ flag which specifies if this socket require a message part with the address (usually for publish/subscribe pattern). | |
void | log (LogLevel level, std::string message) const override |
Log a message to the default logger of this node. | |
virtual void | spinOnce () |
Process incoming messages and call callbacks. | |
void | setRemoteAddress (std::string addr) |
Set the remote address the socket will connect to. | |
std::string | getName () const |
Return the name of the socket bus. | |
Node & | getNode () const |
Return the node owning this socket. | |
bool | matchesPattern (const std::string &pattern) const |
Check if this socket name matches the specified pattern. More... | |
virtual void | readRaw (std::string &msg) |
Read a raw payload from the underlying ZeroMQ socket. | |
virtual void | readRaw (std::string &msg, std::string &type) |
Read a raw payload with type from the underlying ZeroMQ socket. | |
virtual bool | poll (long timeout=0) |
Poll for messages. If timeout is 0 return immediately, otherwise wait for the specified amount of milliseconds. | |
virtual void | writeRaw (const std::string &msg, const std::string &type="") |
Write a raw payload. | |
void | setCompression (std::string algorithm, int level=-1) |
Set compression algorithm and level. More... | |
int | getReadTimeout () const |
(low-level socket option) Get read timeout (in milliseconds, -1 for no timeout) | |
void | setReadTimeout (int timeout) |
(low-level socket option) Set read timeout (in milliseconds, -1 for no timeout) | |
int | getWriteTimeout () const |
(low-level socket option) Get write timeout (in milliseconds, -1 for no timeout) | |
void | setWriteTimeout (int timeout) |
(low-level socket option) Set write timeout (in milliseconds, -1 for no timeout) | |
int | getLingerPeriod () const |
(low-level socket option) Get linger period (in milliseconds, -1 for no timeout) | |
void | setLingerPeriod (int period) |
(low-level socket option) Set linger period (in milliseconds, -1 for no timeout) | |
int | getBacklog () const |
(low-level socket option) Get backlog | |
void | setBacklog (int backlog) |
(low-level socket option) Set backlog | |
bool | getImmediate () const |
(low-level socket option) Get immediate flag | |
void | setImmediate (bool immediate) |
(low-level socket option) Set immediate flag | |
bool | getConflate () const |
(low-level socket option) Get conflate flag | |
void | setConflate (bool conflate) |
(low-level socket option) Set conflate flag | |
int | getReadHWM () const |
(low-level socket option) Get read high-water-mark | |
void | setReadHWM (int n) |
(low-level socket option) Set read high-water-mark | |
int | getWriteHWM () const |
(low-level socket option) Get write high-water-mark | |
void | setWriteHWM (int n) |
(low-level socket option) Set write high-water-mark | |
Public Member Functions inherited from b0::logger::LogInterface | |
template<typename... Arguments> | |
void | log (LogLevel level, std::string const &fmt, Arguments &&... args) const |
Log a message using a format string. | |
Protected Member Functions | |
virtual void | resolve () |
Perform service address resolution. | |
virtual void | connect () |
Connect to service server endpoint. | |
virtual void | disconnect () |
Disconnect from service server endpoint. | |
Protected Member Functions inherited from b0::Socket | |
void | connect (std::string const &addr) |
Wrapper to zmq::socket_t::connect. | |
void | disconnect (std::string const &addr) |
Wrapper to zmq::socket_t::disconnect. | |
void | bind (std::string const &addr) |
Wrapper to zmq::socket_t::bind. | |
void | unbind (std::string const &addr) |
Wrapper to zmq::socket_t::unbind. | |
void | setsockopt (int option, const void *optval, size_t optvallen) |
Wrapper to zmq::socket_t::setsockopt. | |
void | getsockopt (int option, void *optval, size_t *optvallen) const |
Wrapper to zmq::socket_t::getsockopt. | |
void | setIntOption (int option, int value) |
High level wrapper for setsockopt. | |
int | getIntOption (int option) const |
High level wrapper for getsockopt. | |
Protected Attributes | |
const bool | notify_graph_ |
If false this socket will not send announcement to resolv (i.e. it will be "invisible") | |
Protected Attributes inherited from b0::Socket | |
Node & | node_ |
The Node owning this Socket. | |
std::string | name_ |
This socket bus name. | |
bool | has_header_ |
True if the payload has a header part (i.e. More... | |
const bool | managed_ |
True if this socket is managed (init(), cleanup() are called by the owner Node) | |
std::string | remote_addr_ |
The address of the ZeroMQ socket to connect to (will skip name resolution if given) | |
Additional Inherited Members | |
Public Types inherited from b0::logger::LogInterface | |
enum | LogLevel { trace = 0, debug = 10, info = 20, warn = 30, error = 40, fatal = 50 } |
The service client class.
This class wraps a REQ socket. It will automatically resolve the address of service name.
|
virtual |
Write a request and read a reply from the underlying ZeroMQ REQ socket.