-
Notifications
You must be signed in to change notification settings - Fork 140
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
async command callback invoking policy when disconnecting #57
Comments
Yes, this is expected behavior. But this is wrong and I want the handler to be called in case of errors. RedisSyncClient already has the argument boost::system::error_code. |
@nekipelov , thank you for the answer. You mean For example, the current https://github.com/nekipelov/redisclient/blob/v0.6.1/src/redisclient/redisasyncclient.h#L66 REDIS_CLIENT_DECL void command(
const std::string &cmd, std::deque<RedisBuffer> args,
std::function<void(RedisValue)> handler = dummyHandler); and REDIS_CLIENT_DECL void connect(
const boost::asio::ip::tcp::endpoint &endpoint,
std::function<void(boost::system::error_code)> handler); So REDIS_CLIENT_DECL void command(
const std::string &cmd, std::deque<RedisBuffer> args,
std::function<void(RedisValue, boost::system::error_code)> handler = dummyHandler); Anyway, if disconnect is detected, both the installed error handler by |
REDIS_CLIENT_DECL void command(
const std::string &cmd, std::deque<RedisBuffer> args,
std::function<void(RedisValue, boost::system::error_code)> handler); |
What happens in the following case?
Now, no |
You can use Redis server can be excluded from cluster. Someone can unplugging ethernet wire from server. Implementation with |
I understand. Thank you for the comment. |
I have a question about the policy of invoking callback handler.
When I call
RedisAsyncClient::command()
during disconnected, callback function doesn't seems to be called. Is that intentional specification?Here is the small example code that demonstrates the behavior.
I've tested it with f55ffdc.
When I run the program, the following message is appeared:
Then if I do nothing within 5 seconds, I got the following message:
The last line (43) indicates that
RedisAsyncClient::command()
callback is called.If I restart redis service within 5 seconds, I got the following message:
I do
sudo systemctl restart redis.service
.That indicates that
RedisAsyncClient::command()
callback is NOT called. But the handler that is installed usingRedis::installErrorHandler()
is called.Is that expected behavior?
I want to implement automatic re-execute
RedisAsyncClient::command()
mechanism if the redis connection is disconnected.In order to do that, I think that the following mechanism is required:
RedisAsyncClient::command()
, I copy the contents of the command and push it to the queue.RedisAsyncClient::command()
callback is called, erase the pushed command. If installed error handler is called, reconnect to redis, and when reconnected, callRedisAsyncClient::command()
for each commands in the queue.Before I implement it in my client program, I'd like to clarify the library spec.
The text was updated successfully, but these errors were encountered: