Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stop using deprecated functions #112

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions zmq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
#include "utils/exception.h"
#include <array>

void z_send(zmq::socket_t& socket, const std::string& str, int flags) {
void z_send(zmq::socket_t& socket, const std::string& str, zmq::send_flags flags) {
zmq::message_t msg(str.size());
std::memcpy(msg.data(), str.c_str(), str.size());
socket.send(msg, flags);
}

void z_send(zmq::socket_t& socket, zmq::message_t& msg, int flags) {
void z_send(zmq::socket_t& socket, zmq::message_t& msg, zmq::send_flags flags) {
socket.send(msg, flags);
}

std::string z_recv(zmq::socket_t& socket) {
zmq::message_t msg;
socket.recv(&msg);
socket.recv(msg, zmq::recv_flags::none);
return std::string(static_cast<char*>(msg.data()), msg.size());
}

Expand Down Expand Up @@ -73,7 +73,7 @@ void LoadBalancer::run() {

// send every remaining frames to the client
for (size_t idx = 0; idx < frames.size() - 1; ++ idx) {
z_send(clients, frames[idx], ZMQ_SNDMORE);
z_send(clients, frames[idx], zmq::send_flags::sndmore);
}
z_send(clients, frames.back());

Expand Down Expand Up @@ -117,13 +117,13 @@ void LoadBalancer::run() {
// let's forward the message to the workers

// a first frame identifying the worker to route the request to
z_send(workers, worker_addr, ZMQ_SNDMORE);
z_send(workers, worker_addr, zmq::send_flags::sndmore);
// then an empty frame
z_send(workers, "", ZMQ_SNDMORE);
z_send(workers, "", zmq::send_flags::sndmore);

// and then the message from the client
for (size_t idx = 0; idx < frames.size() - 1; ++ idx) {
z_send(workers, frames[idx], ZMQ_SNDMORE);
z_send(workers, frames[idx], zmq::send_flags::sndmore);
}
z_send(workers, frames.back());
}
Expand Down
4 changes: 2 additions & 2 deletions zmq.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ www.navitia.io

#include <stack>

void z_send(zmq::socket_t& socket, const std::string& str, int flags = 0);
void z_send(zmq::socket_t& socket, zmq::message_t& msg, int flags = 0);
void z_send(zmq::socket_t& socket, const std::string& str, zmq::send_flags flags=zmq::send_flags::none);
void z_send(zmq::socket_t& socket, zmq::message_t& msg, zmq::send_flags flags=zmq::send_flags::none);
std::string z_recv(zmq::socket_t& socket);

class LoadBalancer {
Expand Down