Skip to content

Commit 92b9810

Browse files
committed
refactor(datapath): remove dead code after proto refactors
Remove methods that have no callers after the lazy-decode and flat-bytes proto changes: - ProtoPublish::is_command / get_application_payload / get_command_payload - SlimHeader::set_error_flag (duplicate of set_error) - ProtoMessage::set_error_flag (same) - ProtoName::name_id (redundant: id() + NULL_COMPONENT check) Also fix minor issues: - Redundant destructure in subscription_table remove_connection loop - Clippy: &str passed where str suffices in session_controller verify call Signed-off-by: Sam Betts <1769706+Tehsmash@users.noreply.github.com>
1 parent dda1f88 commit 92b9810

4 files changed

Lines changed: 3 additions & 54 deletions

File tree

‎data-plane/core/datapath/src/api.rs‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,6 @@ impl ProtoName {
221221
decode_name_bytes(&self.encoded_name).map_or(NULL_COMPONENT, |(_, _, _, id)| id)
222222
}
223223

224-
/// Returns the ID as an `Option<u128>` — `None` when the ID is `NULL_COMPONENT`.
225-
pub fn name_id(&self) -> Option<u128> {
226-
let id = self.id();
227-
if id == NULL_COMPONENT { None } else { Some(id) }
228-
}
229-
230224
/// Returns the ID as a human-readable string.
231225
pub fn string_id(&self) -> String {
232226
id_to_string(self.id())

‎data-plane/core/datapath/src/messages/utils.rs‎

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,6 @@ impl SlimHeader {
391391
self.incoming_conn = incoming_conn;
392392
}
393393

394-
pub fn set_error_flag(&mut self, error: Option<bool>) {
395-
self.error = error;
396-
}
397-
398394
pub fn get_ttl(&self) -> u32 {
399395
self.ttl
400396
}
@@ -590,42 +586,6 @@ impl ProtoPublish {
590586
self.msg = payload.encode_to_vec().into();
591587
}
592588

593-
pub fn is_command(&self) -> bool {
594-
match self
595-
.get_payload()
596-
.expect("msg must be set")
597-
.content_type
598-
.as_ref()
599-
.unwrap()
600-
{
601-
ContentType::AppPayload(_) => false,
602-
ContentType::CommandPayload(_) => true,
603-
}
604-
}
605-
606-
pub fn get_application_payload(&self) -> ApplicationPayload {
607-
match self
608-
.get_payload()
609-
.expect("msg must be set")
610-
.content_type
611-
.unwrap()
612-
{
613-
ContentType::AppPayload(application_payload) => application_payload,
614-
ContentType::CommandPayload(_) => panic!("the payload is not an application payload"),
615-
}
616-
}
617-
618-
pub fn get_command_payload(&self) -> CommandPayload {
619-
match self
620-
.get_payload()
621-
.expect("msg must be set")
622-
.content_type
623-
.unwrap()
624-
{
625-
ContentType::AppPayload(_) => panic!("the payload is not a command payload"),
626-
ContentType::CommandPayload(command_payload) => command_payload,
627-
}
628-
}
629589
}
630590

631591
/// From ProtoMessage to ProtoPublish
@@ -926,10 +886,6 @@ impl ProtoMessage {
926886
self.get_slim_header_mut().set_incoming_conn(incoming_conn);
927887
}
928888

929-
pub fn set_error_flag(&mut self, error: Option<bool>) {
930-
self.get_slim_header_mut().set_error_flag(error);
931-
}
932-
933889
pub fn get_ttl(&self) -> u32 {
934890
self.get_slim_header().get_ttl()
935891
}

‎data-plane/core/datapath/src/tables/subscription_table.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,7 @@ impl SubscriptionTable for SubscriptionTableImpl {
644644
// Pass 2: clone snapshot, remove conn from routing for every affected encoded name.
645645
let mut rs = (**current).clone();
646646
drop(current);
647-
for (prefix, id) in &encoded_names {
648-
let (prefix, id) = (*prefix, *id);
647+
for &(prefix, id) in &encoded_names {
649648
debug!(%conn, ?prefix, id, "remove subscription");
650649

651650
let should_remove_prefix = if let Some(entry) = rs.get_mut(&prefix) {

‎data-plane/core/session/src/session_controller.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ where
3737
V: Verifier + Send + Sync,
3838
{
3939
let identity = msg.get_slim_header().get_identity();
40-
if verifier.try_verify(&identity).is_err() {
41-
verifier.verify(&identity).await?;
40+
if verifier.try_verify(identity).is_err() {
41+
verifier.verify(identity).await?;
4242
}
4343
Ok(())
4444
}

0 commit comments

Comments
 (0)