Skip to content

Commit

Permalink
Admin space: return reply for '/@/router/<pid>' with json encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
JEnoch committed Aug 25, 2020
1 parent 51e7ba3 commit 4245233
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions zenoh-router/src/runtime/adminspace.rs
Expand Up @@ -20,8 +20,8 @@ use log::trace;
use serde_json::json;
use zenoh_protocol::{
core::{queryable::EVAL, PeerId, QueryConsolidation, QueryTarget, ResKey, SubInfo, ZInt},
io::RBuf,
proto::Primitives,
io::{RBuf, WBuf},
proto::{encoding, DataInfo, Primitives},
};

pub struct AdminSpace {
Expand Down Expand Up @@ -171,11 +171,28 @@ impl Primitives for AdminSpace {
let primitives = self.primitives.lock().await.as_ref().unwrap().clone();
let reskey = ResKey::RName(self.router_path.clone());
let replier_id = self.runtime.read().await.pid.clone(); // @TODO build/use prebuilt specific pid

let data_info = DataInfo {
source_id: None,
source_sn: None,
first_broker_id: None,
first_broker_sn: None,
timestamp: None,
kind: None,
encoding: Some(encoding::APP_JSON),
};
let mut infobuf = WBuf::new(16, false);
infobuf.write_datainfo(&data_info);
task::spawn(async move {
// router is not re-entrant
primitives
.reply_data(qid, EVAL, replier_id.clone(), reskey, None, payload)
.reply_data(
qid,
EVAL,
replier_id.clone(),
reskey,
Some(infobuf.into()),
payload,
)
.await;
primitives.reply_final(qid).await;
});
Expand Down

0 comments on commit 4245233

Please sign in to comment.