Skip to content
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

Make IO functions return StatusOr #1192

Merged
merged 12 commits into from
Dec 21, 2022

Conversation

PragmaTwice
Copy link
Member

@PragmaTwice PragmaTwice commented Dec 17, 2022

Before this PR:

int sock_fd = 0;

Status s = Util::SockConnect(this->host_, this->port_, &sock_fd);
if (!s.IsOK()) {
    return Status(Status::NotOK, "connect the server err: " + s.Msg());
}

useInSomeFunction(sock_fd);

After this PR:

int sock_fd = GET_OR_RET(Util::SockConnect(this->host_, this->port_).Prefixed("connect the server err"));

useInSomeFunction(sock_fd);

or even more simple:

useInSomeFunction(GET_OR_RET(Util::SockConnect(this->host_, this->port_).Prefixed("connect the server err")));

@PragmaTwice PragmaTwice changed the title Make io functions return StatusOr Make IO functions return StatusOr Dec 17, 2022
src/common/io_util.cc Outdated Show resolved Hide resolved
utils/kvrocks2redis/sync.cc Outdated Show resolved Hide resolved
torwig
torwig previously approved these changes Dec 17, 2022
Copy link
Contributor

@torwig torwig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@PragmaTwice
Copy link
Member Author

Thanks all. Merging...

@PragmaTwice PragmaTwice merged commit 5515ccc into apache:unstable Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants