-
Notifications
You must be signed in to change notification settings - Fork 990
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
feat: Use const ConnectionContext in VerifyCommand #1633
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -220,6 +220,14 @@ void RedisReplyBuilder::SendError(string_view str, string_view err_type) { | |
} | ||
} | ||
|
||
void RedisReplyBuilder::SendError(ErrorReply error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see that you move anything from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure. Forgot to comment about it. I want the CapturingReplyBuilder to move out of the string so it can re-use its memory. The downside is that it requires passing the error by value everyewhere to comply with the interface |
||
if (error.status) | ||
return SendError(*error.status); | ||
|
||
string_view message_sv = visit([](auto&& str) -> string_view { return str; }, error.message); | ||
SendError(message_sv, error.kind); | ||
} | ||
|
||
void RedisReplyBuilder::SendProtocolError(std::string_view str) { | ||
SendError(absl::StrCat("-ERR Protocol error: ", str), "protocol_error"); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can have
message
of typestring_view
, and some other member (like privatemessage_memory_
) whichmessage
may or may not point into?It should make using this struct easier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember you don't like using variants for storage at all, we already had this case once.
But I like to avoid self referential structs - it requires defining move/copy constructors and operators
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not worried about performance implications of using std::string in case we return errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is why I use string_view whenever its possible, in other cases you construct a string with StrCat and others anyways
I'll check once again for performance degradation, but it shouldn't be the case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw I once thought of supporting an
absl::Span<absl::Alphanumeric>
interface to write directly into the conn buffer without the intermediary string, but its just a random comment in this context 🙂There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So yes, I don't see any place where the number of intermediaries increased
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant - I am NOT worried - i.e. I think having a string here is perfectly fine since it's not on a hot path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any problem with storing
variant
as a member, or using it as storage. I actually thinkvariant
s are great.I dislike the API that it brings in, though. I definitely understand your comment re/ having to implement an explicit move / copy operations.
I guess we could:
string_view
which points to the right stringstring
inside aunique_ptr
string
(Roman's suggestion)Your call :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you decided to keep as is. I would still say it's not a great API to force a call to
std::visit
with a templated lambda instead of having aTo wrap that, but again, your call :)
For the case where you want to move if possible, you could have another version (
GetMessageDestructive()
?)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😝
As soon as it'll be used more than in once place I'll add those