Skip to content

Commit 63894ec

Browse files
committed
don't compute full expr to initialize RoutingContext
1 parent 1cf9158 commit 63894ec

File tree

18 files changed

+526
-518
lines changed

18 files changed

+526
-518
lines changed

zenoh/src/net/primitives/mux.rs

Lines changed: 24 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,12 @@ impl Mux {
4848
impl EPrimitives for Mux {
4949
fn send_interest(&self, ctx: RoutingContext<Interest>) {
5050
let interest_id = ctx.msg.id;
51-
let ctx = RoutingContext {
52-
msg: NetworkMessage {
53-
body: NetworkBody::Interest(ctx.msg),
54-
reliability: Reliability::Reliable,
55-
#[cfg(feature = "stats")]
56-
size: None,
57-
},
58-
inface: ctx.inface,
59-
outface: ctx.outface,
60-
prefix: ctx.prefix,
61-
full_expr: ctx.full_expr,
62-
};
51+
let ctx = ctx.map_msg(|msg| NetworkMessage {
52+
body: NetworkBody::Interest(msg),
53+
reliability: Reliability::Reliable,
54+
#[cfg(feature = "stats")]
55+
size: None,
56+
});
6357
let prefix = ctx
6458
.wire_expr()
6559
.and_then(|we| (!we.has_suffix()).then(|| ctx.prefix()))
@@ -83,18 +77,12 @@ impl EPrimitives for Mux {
8377
}
8478

8579
fn send_declare(&self, ctx: RoutingContext<Declare>) {
86-
let ctx = RoutingContext {
87-
msg: NetworkMessage {
88-
body: NetworkBody::Declare(ctx.msg),
89-
reliability: Reliability::Reliable,
90-
#[cfg(feature = "stats")]
91-
size: None,
92-
},
93-
inface: ctx.inface,
94-
outface: ctx.outface,
95-
prefix: ctx.prefix,
96-
full_expr: ctx.full_expr,
97-
};
80+
let ctx = ctx.map_msg(|msg| NetworkMessage {
81+
body: NetworkBody::Declare(msg),
82+
reliability: Reliability::Reliable,
83+
#[cfg(feature = "stats")]
84+
size: None,
85+
});
9886
let prefix = ctx
9987
.wire_expr()
10088
.and_then(|we| (!we.has_suffix()).then(|| ctx.prefix()))
@@ -243,18 +231,12 @@ impl McastMux {
243231

244232
impl EPrimitives for McastMux {
245233
fn send_interest(&self, ctx: RoutingContext<Interest>) {
246-
let ctx = RoutingContext {
247-
msg: NetworkMessage {
248-
body: NetworkBody::Interest(ctx.msg),
249-
reliability: Reliability::Reliable,
250-
#[cfg(feature = "stats")]
251-
size: None,
252-
},
253-
inface: ctx.inface,
254-
outface: ctx.outface,
255-
prefix: ctx.prefix,
256-
full_expr: ctx.full_expr,
257-
};
234+
let ctx = ctx.map_msg(|msg| NetworkMessage {
235+
body: NetworkBody::Interest(msg),
236+
reliability: Reliability::Reliable,
237+
#[cfg(feature = "stats")]
238+
size: None,
239+
});
258240
let prefix = ctx
259241
.wire_expr()
260242
.and_then(|we| (!we.has_suffix()).then(|| ctx.prefix()))
@@ -269,18 +251,12 @@ impl EPrimitives for McastMux {
269251
}
270252

271253
fn send_declare(&self, ctx: RoutingContext<Declare>) {
272-
let ctx = RoutingContext {
273-
msg: NetworkMessage {
274-
body: NetworkBody::Declare(ctx.msg),
275-
reliability: Reliability::Reliable,
276-
#[cfg(feature = "stats")]
277-
size: None,
278-
},
279-
inface: ctx.inface,
280-
outface: ctx.outface,
281-
prefix: ctx.prefix,
282-
full_expr: ctx.full_expr,
283-
};
254+
let ctx = ctx.map_msg(|msg| NetworkMessage {
255+
body: NetworkBody::Declare(msg),
256+
reliability: Reliability::Reliable,
257+
#[cfg(feature = "stats")]
258+
size: None,
259+
});
284260
let prefix = ctx
285261
.wire_expr()
286262
.and_then(|we| (!we.has_suffix()).then(|| ctx.prefix()))

zenoh/src/net/routing/dispatcher/resource.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ impl Resource {
508508
get_mut_unchecked(face)
509509
.local_mappings
510510
.insert(expr_id, nonwild_prefix.clone());
511-
face.primitives.send_declare(RoutingContext::with_expr(
511+
face.primitives.send_declare(RoutingContext::with_resource(
512512
Declare {
513513
interest_id: None,
514514
ext_qos: ext::QoSType::DECLARE,
@@ -519,7 +519,7 @@ impl Resource {
519519
wire_expr: nonwild_prefix.expr().into(),
520520
}),
521521
},
522-
nonwild_prefix.expr(),
522+
nonwild_prefix.clone(),
523523
));
524524
face.update_interceptors_caches(&mut nonwild_prefix);
525525
WireExpr {

zenoh/src/net/routing/hat/client/interests.rs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub(super) fn interests_new_face(tables: &mut Tables, face: &mut Arc<FaceState>)
5858
},
5959
);
6060
let wire_expr = res.as_ref().map(|res| Resource::decl_key(res, face, true));
61-
face.primitives.send_interest(RoutingContext::with_expr(
61+
face.primitives.send_interest(RoutingContext::with_resource(
6262
Interest {
6363
id,
6464
mode: InterestMode::CurrentFuture,
@@ -68,7 +68,7 @@ pub(super) fn interests_new_face(tables: &mut Tables, face: &mut Arc<FaceState>)
6868
ext_tstamp: None,
6969
ext_nodeid: ext::NodeIdType::DEFAULT,
7070
},
71-
res.as_ref().map(|res| res.expr()).unwrap_or_default(),
71+
res.clone(),
7272
));
7373
}
7474
}
@@ -149,18 +149,20 @@ impl HatInterestTrait for HatCode {
149149
let wire_expr = res
150150
.as_ref()
151151
.map(|res| Resource::decl_key(res, dst_face, true));
152-
dst_face.primitives.send_interest(RoutingContext::with_expr(
153-
Interest {
154-
id,
155-
mode,
156-
options,
157-
wire_expr,
158-
ext_qos: ext::QoSType::DECLARE,
159-
ext_tstamp: None,
160-
ext_nodeid: ext::NodeIdType::DEFAULT,
161-
},
162-
res.as_ref().map(|res| res.expr()).unwrap_or_default(),
163-
));
152+
dst_face
153+
.primitives
154+
.send_interest(RoutingContext::with_resource(
155+
Interest {
156+
id,
157+
mode,
158+
options,
159+
wire_expr,
160+
ext_qos: ext::QoSType::DECLARE,
161+
ext_tstamp: None,
162+
ext_nodeid: ext::NodeIdType::DEFAULT,
163+
},
164+
res.as_deref().cloned(),
165+
));
164166
}
165167

166168
if mode.current() {
@@ -221,24 +223,22 @@ impl HatInterestTrait for HatCode {
221223
if local_interest.res == interest.res
222224
&& local_interest.options == interest.options
223225
{
224-
dst_face.primitives.send_interest(RoutingContext::with_expr(
225-
Interest {
226-
id,
227-
mode: InterestMode::Final,
228-
// Note: InterestMode::Final options are undefined in the current protocol specification,
229-
// they are initialized here for internal use by local egress interceptors.
230-
options: interest.options,
231-
wire_expr: None,
232-
ext_qos: ext::QoSType::DECLARE,
233-
ext_tstamp: None,
234-
ext_nodeid: ext::NodeIdType::DEFAULT,
235-
},
236-
local_interest
237-
.res
238-
.as_ref()
239-
.map(|res| res.expr())
240-
.unwrap_or_default(),
241-
));
226+
dst_face
227+
.primitives
228+
.send_interest(RoutingContext::with_resource(
229+
Interest {
230+
id,
231+
mode: InterestMode::Final,
232+
// Note: InterestMode::Final options are undefined in the current protocol specification,
233+
// they are initialized here for internal use by local egress interceptors.
234+
options: interest.options,
235+
wire_expr: None,
236+
ext_qos: ext::QoSType::DECLARE,
237+
ext_tstamp: None,
238+
ext_nodeid: ext::NodeIdType::DEFAULT,
239+
},
240+
local_interest.res.clone(),
241+
));
242242
get_mut_unchecked(dst_face).local_interests.remove(&id);
243243
}
244244
}

zenoh/src/net/routing/hat/client/pubsub.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn propagate_simple_subscription_to(
5959
let key_expr = Resource::decl_key(res, dst_face, true);
6060
send_declare(
6161
&dst_face.primitives,
62-
RoutingContext::with_expr(
62+
RoutingContext::with_resource(
6363
Declare {
6464
interest_id: None,
6565
ext_qos: ext::QoSType::DECLARE,
@@ -70,7 +70,7 @@ fn propagate_simple_subscription_to(
7070
wire_expr: key_expr,
7171
}),
7272
},
73-
res.expr(),
73+
res.clone(),
7474
),
7575
);
7676
}
@@ -164,7 +164,7 @@ fn propagate_forget_simple_subscription(
164164
if let Some(id) = face_hat_mut!(face).local_subs.remove(res) {
165165
send_declare(
166166
&face.primitives,
167-
RoutingContext::with_expr(
167+
RoutingContext::with_resource(
168168
Declare {
169169
interest_id: None,
170170
ext_qos: ext::QoSType::DECLARE,
@@ -175,7 +175,7 @@ fn propagate_forget_simple_subscription(
175175
ext_wire_expr: WireExprType::null(),
176176
}),
177177
},
178-
res.expr(),
178+
res.clone(),
179179
),
180180
);
181181
}
@@ -202,7 +202,7 @@ pub(super) fn undeclare_simple_subscription(
202202
if let Some(id) = face_hat_mut!(face).local_subs.remove(res) {
203203
send_declare(
204204
&face.primitives,
205-
RoutingContext::with_expr(
205+
RoutingContext::with_resource(
206206
Declare {
207207
interest_id: None,
208208
ext_qos: ext::QoSType::DECLARE,
@@ -213,7 +213,7 @@ pub(super) fn undeclare_simple_subscription(
213213
ext_wire_expr: WireExprType::null(),
214214
}),
215215
},
216-
res.expr(),
216+
res.clone(),
217217
),
218218
);
219219
}

zenoh/src/net/routing/hat/client/queries.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ fn propagate_simple_queryable(
108108
let key_expr = Resource::decl_key(res, &mut dst_face, true);
109109
send_declare(
110110
&dst_face.primitives,
111-
RoutingContext::with_expr(
111+
RoutingContext::with_resource(
112112
Declare {
113113
interest_id: None,
114114
ext_qos: ext::QoSType::DECLARE,
@@ -120,7 +120,7 @@ fn propagate_simple_queryable(
120120
ext_info: info,
121121
}),
122122
},
123-
res.expr(),
123+
res.clone(),
124124
),
125125
);
126126
}
@@ -182,7 +182,7 @@ fn propagate_forget_simple_queryable(
182182
if let Some((id, _)) = face_hat_mut!(face).local_qabls.remove(res) {
183183
send_declare(
184184
&face.primitives,
185-
RoutingContext::with_expr(
185+
RoutingContext::with_resource(
186186
Declare {
187187
interest_id: None,
188188
ext_qos: ext::QoSType::DECLARE,
@@ -193,7 +193,7 @@ fn propagate_forget_simple_queryable(
193193
ext_wire_expr: WireExprType::null(),
194194
}),
195195
},
196-
res.expr(),
196+
res.clone(),
197197
),
198198
);
199199
}
@@ -226,7 +226,7 @@ pub(super) fn undeclare_simple_queryable(
226226
if let Some((id, _)) = face_hat_mut!(face).local_qabls.remove(res) {
227227
send_declare(
228228
&face.primitives,
229-
RoutingContext::with_expr(
229+
RoutingContext::with_resource(
230230
Declare {
231231
interest_id: None,
232232
ext_qos: ext::QoSType::DECLARE,
@@ -237,7 +237,7 @@ pub(super) fn undeclare_simple_queryable(
237237
ext_wire_expr: WireExprType::null(),
238238
}),
239239
},
240-
res.expr(),
240+
res.clone(),
241241
),
242242
);
243243
}

0 commit comments

Comments
 (0)