-
Notifications
You must be signed in to change notification settings - Fork 85
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
Implement error reply support #523
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1218,19 +1218,11 @@ int8_t z_get(const z_loaned_session_t *zs, const z_loaned_keyexpr_t *keyexpr, co | |
return ret; | ||
} | ||
|
||
_Bool z_reply_is_ok(const z_loaned_reply_t *reply) { | ||
_ZP_UNUSED(reply); | ||
// For the moment always return TRUE. | ||
// FIXME: The support for reply errors will come in the next release. | ||
return true; | ||
} | ||
_Bool z_reply_is_ok(const z_loaned_reply_t *reply) { return reply->_tag != _Z_REPLY_TAG_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. With this modification, this PR probably closes #345 as well. 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. Seems, yes |
||
|
||
const z_loaned_sample_t *z_reply_ok(const z_loaned_reply_t *reply) { return &reply->data.sample; } | ||
|
||
const z_loaned_reply_err_t *z_reply_err(const z_loaned_reply_t *reply) { | ||
_ZP_UNUSED(reply); | ||
return NULL; | ||
} | ||
const z_loaned_reply_err_t *z_reply_err(const z_loaned_reply_t *reply) { return &reply->data.error; } | ||
#endif | ||
|
||
#if Z_FEATURE_QUERYABLE == 1 | ||
|
@@ -1361,6 +1353,34 @@ int8_t z_query_reply_del(const z_loaned_query_t *query, const z_loaned_keyexpr_t | |
z_bytes_drop(opts.attachment); | ||
return ret; | ||
} | ||
|
||
void z_query_reply_err_options_default(z_query_reply_err_options_t *options) { options->encoding = NULL; } | ||
|
||
int8_t z_query_reply_err(const z_loaned_query_t *query, z_owned_bytes_t *payload, | ||
const z_query_reply_err_options_t *options) { | ||
// Try upgrading session weak to rc | ||
_z_session_rc_t sess_rc = _z_session_weak_upgrade(&query->in->val._zn); | ||
if (sess_rc.in == NULL) { | ||
return _Z_ERR_CONNECTION_CLOSED; | ||
} | ||
z_query_reply_err_options_t opts; | ||
if (options == NULL) { | ||
z_query_reply_err_options_default(&opts); | ||
} else { | ||
opts = *options; | ||
} | ||
// Set value | ||
_z_value_t value = {.payload = _z_bytes_from_owned_bytes(payload), | ||
.encoding = _z_encoding_from_owned(opts.encoding)}; | ||
|
||
int8_t ret = _z_send_reply_err(&query->in->val, &sess_rc, value); | ||
if (payload != NULL) { | ||
z_bytes_drop(payload); | ||
} | ||
// Clean-up | ||
z_encoding_drop(opts.encoding); | ||
return ret; | ||
} | ||
#endif | ||
|
||
int8_t z_keyexpr_from_str_autocanonize(z_owned_keyexpr_t *key, const char *name) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
df
->d:f
?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.
No, ":" means that option value expected
https://www.man7.org/linux/man-pages/man3/getopt.3.html