Skip to content

Commit

Permalink
Add missed z_query_reply_options_t fields (#509)
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc authored Jul 5, 2024
1 parent 9e73622 commit e439767
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
8 changes: 8 additions & 0 deletions include/zenoh-pico/api/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,18 @@ typedef struct {
*
* Members:
* z_owned_encoding_t *encoding: The encoding of the payload.
* z_congestion_control_t congestion_control: The congestion control to apply when routing this message.
* z_priority_t priority: The priority of this message when routed.
* z_timestamp_t *timestamp: The API level timestamp (e.g. of the data when it was created).
* _Bool is_express: If true, Zenoh will not wait to batch this operation with others to reduce the bandwith.
* z_owned_bytes_t *attachment: An optional attachment to the response.
*/
typedef struct {
z_owned_encoding_t *encoding;
z_congestion_control_t congestion_control;
z_priority_t priority;
z_timestamp_t *timestamp;
_Bool is_express;
z_owned_bytes_t *attachment;
} z_query_reply_options_t;

Expand Down
3 changes: 2 additions & 1 deletion include/zenoh-pico/net/primitives.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ int8_t _z_undeclare_queryable(_z_queryable_t *qle);
* attachment: An optional attachment to the reply.
*/
int8_t _z_send_reply(const _z_query_t *query, const _z_keyexpr_t keyexpr, const _z_value_t payload,
const z_sample_kind_t kind, const _z_bytes_t attachment);
const z_sample_kind_t kind, const z_congestion_control_t cong_ctrl, z_priority_t priority,
_Bool is_express, const _z_timestamp_t *timestamp, const _z_bytes_t attachment);
#endif

#if Z_FEATURE_QUERY == 1
Expand Down
7 changes: 6 additions & 1 deletion src/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,10 @@ int8_t z_undeclare_queryable(z_owned_queryable_t *queryable) {

void z_query_reply_options_default(z_query_reply_options_t *options) {
options->encoding = NULL;
options->priority = Z_PRIORITY_DEFAULT;
options->encoding = NULL;
options->timestamp = NULL;
options->is_express = false;
options->attachment = NULL;
}

Expand All @@ -1221,7 +1225,8 @@ int8_t z_query_reply(const z_loaned_query_t *query, const z_loaned_keyexpr_t *ke
.encoding = _z_encoding_from_owned(opts.encoding)};

int8_t ret =
_z_send_reply(&query->in->val, *keyexpr, value, Z_SAMPLE_KIND_PUT, _z_bytes_from_owned_bytes(opts.attachment));
_z_send_reply(&query->in->val, *keyexpr, value, Z_SAMPLE_KIND_PUT, opts.congestion_control, opts.priority,
opts.is_express, opts.timestamp, _z_bytes_from_owned_bytes(opts.attachment));
if (payload != NULL) {
z_bytes_drop(payload);
}
Expand Down
9 changes: 6 additions & 3 deletions src/net/primitives.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ int8_t _z_undeclare_queryable(_z_queryable_t *qle) {
}

int8_t _z_send_reply(const _z_query_t *query, _z_keyexpr_t keyexpr, const _z_value_t payload,
const z_sample_kind_t kind, const _z_bytes_t att) {
const z_sample_kind_t kind, const z_congestion_control_t cong_ctrl, z_priority_t priority,
_Bool is_express, const _z_timestamp_t *timestamp, const _z_bytes_t att) {
int8_t ret = _Z_RES_OK;

_z_keyexpr_t q_ke;
Expand Down Expand Up @@ -337,14 +338,16 @@ int8_t _z_send_reply(const _z_query_t *query, _z_keyexpr_t keyexpr, const _z_val
z_msg._body._response._key = ke;
z_msg._body._response._ext_responder._zid = zid;
z_msg._body._response._ext_responder._eid = 0;
z_msg._body._response._ext_qos = _Z_N_QOS_DEFAULT;
z_msg._body._response._ext_qos =
_z_n_qos_make(is_express, cong_ctrl == Z_CONGESTION_CONTROL_BLOCK, priority);
z_msg._body._response._ext_timestamp = _z_timestamp_null();
z_msg._body._response._tag = _Z_RESPONSE_BODY_REPLY;
z_msg._body._response._body._reply._consolidation = Z_CONSOLIDATION_MODE_DEFAULT;
z_msg._body._response._body._reply._body._is_put = true;
z_msg._body._response._body._reply._body._body._put._payload = payload.payload;
z_msg._body._response._body._reply._body._body._put._encoding = payload.encoding;
z_msg._body._response._body._reply._body._body._put._commons._timestamp = _z_timestamp_null();
z_msg._body._response._body._reply._body._body._put._commons._timestamp =
(timestamp != NULL) ? *timestamp : _z_timestamp_null();
z_msg._body._response._body._reply._body._body._put._commons._source_info = _z_source_info_null();
z_msg._body._response._body._reply._body._body._put._attachment = att;
break;
Expand Down

0 comments on commit e439767

Please sign in to comment.