Skip to content

API · fair::mq

Channelclass

#include <fairmq/Channel.h>fairmq/Channel.h:36GitHub ↗

Wrapper class for Socket and related methods.

The class is not thread-safe.

Nested types

Functions

Channel(
    const std::string& type,
    const std::string& method,
    const std::string& address
)

Constructor

type
Socket type (push/pull/pub/sub/spub/xsub/pair/req/rep/dealer/router/)
method
Socket method (bind/connect)
address
Network address to bind/connect to (e.g. "tcp://127.0.0.1:5555" or "ipc://abc")
Channel(
    std::string name,
    std::string type,
    std::string method,
    std::string address,
    std::shared_ptr<TransportFactory> factory
)

Constructor

name
Channel name
type
Socket type (push/pull/pub/sub/spub/xsub/pair/req/rep/dealer/router/)
method
Socket method (bind/connect)
address
Network address to bind/connect to (e.g. "tcp://127.0.0.1:5555" or "ipc://abc")
factory
TransportFactory
bool Bind(const std::string& address)

No comment in the header yet.

std::string GetName() const

Get channel name

Returns
Returns full channel name (e.g. "data[0]")
std::string GetPrefix() const

Get channel prefix

Returns
Returns channel prefix (e.g. "data" in "data[0]")
std::string GetIndex() const

Get channel index

Returns
Returns channel index (e.g. 0 in "data[0]")
std::string GetType() const

Get socket type

Returns
Returns socket type (push/pull/pub/sub/spub/xsub/pair/req/rep/dealer/router/)
std::string GetMethod() const

Get socket method

Returns
Returns socket method (bind/connect)
std::string GetAddress() const

Get socket address (e.g. "tcp://127.0.0.1:5555" or "ipc://abc")

Returns
Returns socket address (e.g. "tcp://127.0.0.1:5555" or "ipc://abc")
std::string GetTransportName() const

Get channel transport name ("default", "zeromq" or "shmem")

Returns
Returns channel transport name (e.g. "default", "zeromq" or "shmem")
int GetSndBufSize() const

Get socket send buffer size (in number of messages)

Returns
Returns socket send buffer size (in number of messages)
int GetRcvBufSize() const

Get socket receive buffer size (in number of messages)

Returns
Returns socket receive buffer size (in number of messages)
int GetSndKernelSize() const

Get socket kernel transmit send buffer size (in bytes)

Returns
Returns socket kernel transmit send buffer size (in bytes)
int GetRcvKernelSize() const

Get socket kernel transmit receive buffer size (in bytes)

Returns
Returns socket kernel transmit receive buffer size (in bytes)
int GetSndTimeout() const

Get socket default send timeout (in ms)

Returns
Returns socket default send timeout (in ms)
int GetRcvTimeout() const

Get socket default receive timeout (in ms)

Returns
Returns socket default receive timeout (in ms)
int GetLinger() const

Get linger duration (in milliseconds)

Returns
Returns linger duration (in milliseconds)
int GetRateLogging() const

Get socket rate logging interval (in seconds)

Returns
Returns socket rate logging interval (in seconds)
bool GetAutoBind() const

Set automatic binding (pick random port if bind fails)

Returns
true/false, true if automatic binding is enabled
void UpdateType(const std::string& type)

Set socket type

type
Socket type (push/pull/pub/sub/spub/xsub/pair/req/rep/dealer/router/)
void UpdateAddress(const std::string& address)

Set socket address

Socket
address (e.g. "tcp://127.0.0.1:5555" or "ipc://abc")
void UpdateTransport(const std::string& transport)

Set channel transport

transport
transport string ("default", "zeromq" or "shmem")
void UpdateLinger(int duration)

Set linger duration (in milliseconds)

duration
linger duration (in milliseconds)
void UpdateAutoBind(bool autobind)

Set automatic binding (pick random port if bind fails)

autobind
true/false, true to enable automatic binding
bool IsValid() const

Checks if the configured channel settings are valid (checks the validity parameter, without running full validation (as oposed to ValidateChannel()))

Returns
true if channel settings are valid, false otherwise.
bool Validate()

Validates channel configuration

Returns
true if channel settings are valid, false otherwise.
template<typename M, typename... Timeout>
std::enable_if_t<is_transferrable<M>::value, int64_t> Send(
    M& m,
    Timeout&&... sndTimeoutMs
)

Send message(s) to the socket queue.

m
reference to MessagePtr/Parts/vector<MessagePtr>
sndTimeoutMs
send timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot send). If not provided, default timeout will be taken.
Returns
Number of bytes that have been queued, TransferCode::timeout if timed out, TransferCode::error if there was an error, TransferCode::interrupted if interrupted (e.g. by requested state change)
template<typename M, typename... Timeout>
std::enable_if_t<is_transferrable<M>::value, int64_t> Receive(
    M& m,
    Timeout&&... rcvTimeoutMs
)

Receive message(s) from the socket queue.

m
reference to MessagePtr/Parts/vector<MessagePtr>
rcvTimeoutMs
receive timeout in ms. -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot receive). If not provided, default timeout will be taken.
Returns
Number of bytes that have been received, TransferCode::timeout if timed out, TransferCode::error if there was an error, TransferCode::interrupted if interrupted (e.g. by requested state change)

Static data members

Friends