mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
chore: Remove ReqSerializer (#3721)
Signed-off-by: Vladislav <vladislav.oleshko@gmail.com>
This commit is contained in:
parent
ffb4c2b601
commit
41ba864924
5 changed files with 10 additions and 40 deletions
|
@ -846,13 +846,6 @@ void RedisReplyBuilder::SendStringArrInternal(
|
|||
Send(vec.data(), vec_indx + 1);
|
||||
}
|
||||
|
||||
void ReqSerializer::SendCommand(std::string_view str) {
|
||||
VLOG(2) << "SendCommand: " << str;
|
||||
|
||||
iovec v[] = {IoVec(str), IoVec(kCRLF)};
|
||||
ec_ = sink_->Write(v, ABSL_ARRAYSIZE(v));
|
||||
}
|
||||
|
||||
void RedisReplyBuilder2Base::SendNull() {
|
||||
ReplyScope scope(this);
|
||||
has_replied_ = true;
|
||||
|
@ -964,6 +957,10 @@ void RedisReplyBuilder2Base::SendVerbatimString(std::string_view str, VerbatimFo
|
|||
WritePieces(kCRLF);
|
||||
}
|
||||
|
||||
std::string RedisReplyBuilder2Base::SerializeCommand(std::string_view command) {
|
||||
return string{command} + kCRLF;
|
||||
}
|
||||
|
||||
void RedisReplyBuilder2::SendSimpleStrArr2(const facade::ArgRange& strs) {
|
||||
ReplyScope scope(this);
|
||||
StartArray(strs.Size());
|
||||
|
|
|
@ -422,9 +422,11 @@ class RedisReplyBuilder2Base : public SinkReplyBuilder2, public RedisReplyBuilde
|
|||
void SendError(std::string_view str, std::string_view type = {}) override;
|
||||
void SendProtocolError(std::string_view str) override;
|
||||
|
||||
static char* FormatDouble(double d, char* dest, unsigned len);
|
||||
virtual void SendVerbatimString(std::string_view str, VerbatimFormat format = TXT) override;
|
||||
|
||||
static char* FormatDouble(double d, char* dest, unsigned len);
|
||||
static std::string SerializeCommand(std::string_view command);
|
||||
|
||||
bool IsResp3() const override {
|
||||
return resp3_;
|
||||
}
|
||||
|
@ -496,24 +498,6 @@ class RedisReplyBuilder2 : public RedisReplyBuilder2Base {
|
|||
|
||||
// TODO: Remove
|
||||
void SendMGetResponse(SinkReplyBuilder::MGetResponse resp) override;
|
||||
|
||||
static std::string SerializeCommmand(std::string_view cmd);
|
||||
};
|
||||
|
||||
class ReqSerializer {
|
||||
public:
|
||||
explicit ReqSerializer(::io::Sink* stream) : sink_(stream) {
|
||||
}
|
||||
|
||||
void SendCommand(std::string_view str);
|
||||
|
||||
std::error_code ec() const {
|
||||
return ec_;
|
||||
}
|
||||
|
||||
private:
|
||||
::io::Sink* sink_;
|
||||
std::error_code ec_;
|
||||
};
|
||||
|
||||
} // namespace facade
|
||||
|
|
|
@ -209,7 +209,6 @@ error_code ProtocolClient::ConnectAndAuth(std::chrono::milliseconds connect_time
|
|||
} else {
|
||||
sock_.reset(mythread->CreateSocket());
|
||||
}
|
||||
serializer_ = std::make_unique<ReqSerializer>(sock_.get());
|
||||
} else {
|
||||
return cntx->GetError();
|
||||
}
|
||||
|
@ -385,11 +384,10 @@ bool ProtocolClient::CheckRespFirstTypes(initializer_list<RespExpr::Type> types)
|
|||
}
|
||||
|
||||
error_code ProtocolClient::SendCommand(string_view command) {
|
||||
serializer_->SendCommand(command);
|
||||
error_code ec = serializer_->ec();
|
||||
if (!ec) {
|
||||
string formatted_command = RedisReplyBuilder2Base::SerializeCommand(command);
|
||||
auto ec = sock_->Write(io::Buffer(formatted_command));
|
||||
if (!ec)
|
||||
TouchIoTime();
|
||||
}
|
||||
return ec;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,10 +20,6 @@
|
|||
#include <openssl/ssl.h>
|
||||
#endif
|
||||
|
||||
namespace facade {
|
||||
class ReqSerializer;
|
||||
}; // namespace facade
|
||||
|
||||
namespace dfly {
|
||||
|
||||
class Service;
|
||||
|
@ -117,7 +113,6 @@ class ProtocolClient {
|
|||
private:
|
||||
ServerContext server_context_;
|
||||
|
||||
std::unique_ptr<facade::ReqSerializer> serializer_;
|
||||
std::unique_ptr<facade::RedisParser> parser_;
|
||||
facade::RespVec resp_args_;
|
||||
base::IoBuf resp_buf_;
|
||||
|
|
|
@ -20,10 +20,6 @@
|
|||
#include "server/version.h"
|
||||
#include "util/fiber_socket_base.h"
|
||||
|
||||
namespace facade {
|
||||
class ReqSerializer;
|
||||
}; // namespace facade
|
||||
|
||||
namespace dfly {
|
||||
|
||||
class Service;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue