Commit a44d0dac authored by Georgios Bitzes's avatar Georgios Bitzes
Browse files

Simplify RaftHandshake using qclient Handshake chaining

parent 9d5b106d
Pipeline #425054 passed with stages
in 30 minutes and 2 seconds
Subproject commit 0ef4113c8902d5b79893989a0eaef3354ac79e69
Subproject commit 417793db74422236b2f317229bcf42d06ede5223
......@@ -34,29 +34,15 @@ public:
virtual ~RaftHandshake() override {}
RaftHandshake(const RaftContactDetails &cd)
: contactDetails(cd), authHandshake(cd.getPassword()) {
: contactDetails(cd) {
restart();
}
virtual std::vector<std::string> provideHandshake() override {
if(!authHandshakeDone) {
return authHandshake.provideHandshake();
}
return {"RAFT_HANDSHAKE", VERSION_FULL_STRING, contactDetails.getClusterID(), contactDetails.getRaftTimeouts().toString() };
}
virtual Status validateResponse(const redisReplyPtr &reply) override {
if(!authHandshakeDone) {
Status st = authHandshake.validateResponse(reply);
if(st == Status::INVALID) return Status::INVALID;
if(st == Status::VALID_INCOMPLETE) return Status::VALID_INCOMPLETE;
qdb_assert(st == Status::VALID_COMPLETE);
authHandshakeDone = true;
return Status::VALID_INCOMPLETE;
}
if(!reply) {
return Status::INVALID;
}
......@@ -72,15 +58,10 @@ public:
return Status::VALID_COMPLETE;
}
virtual void restart() override {
authHandshakeDone = contactDetails.getPassword().empty();
authHandshake.restart();
}
virtual void restart() override {}
private:
const RaftContactDetails &contactDetails;
bool authHandshakeDone = false;
qclient::HmacAuthHandshake authHandshake;
};
......@@ -92,7 +73,9 @@ RaftTalker::RaftTalker(const RaftServer &server_, const RaftContactDetails &cont
opts.transparentRedirects = false;
opts.retryStrategy = qclient::RetryStrategy::NoRetries();
opts.backpressureStrategy = qclient::BackpressureStrategy::Default();
opts.handshake.reset(new RaftHandshake(contactDetails));
opts.chainHmacHandshake(contactDetails.getPassword());
opts.chainHandshake(std::unique_ptr<Handshake>(new RaftHandshake(contactDetails)));
qcl.reset(new QClient(server.hostname, server.port, std::move(opts)));
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment