Open neo1986 opened 5 years ago
Hi, @neo1986
This issue is not a problem, This is a specification.
Checkout this code and comment: https://github.com/cpp-redis/cpp_redis/blob/master/examples/cpp_redis_high_availability_client.cpp#L34-L35
So, the cpp_redis::network::set_default_nb_workers(2);
code must be enabled. this code means that io service workers (threads numbers)
.
its default tcp library tacopie threadpool spec.
see:
These variable values(m_workers
, ..._threads
) are initialized to zero.
I found that
const std::shared_ptr<io_service>&
get_default_io_service(std::uint32_t num_io_workers) {
if (io_service_default_instance == nullptr) {
io_service_default_instance = std::make_shared<io_service>(num_io_workers);
}
else {
//this code reset thread_pool to 1
//io_service_default_instance->set_nb_workers(num_io_workers);
}
return io_service_default_instance;
}
Using the example of cpp_redis_high_availability_client Here is my docker-compose file and redis.conf: docker-compose file:
redis-sentinel.conf:
redis-master.conf:
port 8000
redis-slave1.conf:redis-slave2.conf
In the code, If I disable cpp_redis::network::set_default_nb_workers(2);, it will work then I stop the master, it won't try to reconnect the sentinel's new master and the programmer blocked and do nothing. if the cpp_redis::network::set_default_nb_workers(2); enabled, it will do nothing but block on the connect function
cpp-redis is quite great and I think will replace the hiredis sooner or later, please take a look at this issue. the code is running on win with VS2015 and I installed the cpp-redis with vcpkg. please take a look at this issue, thanks a lot