Skip to content

Commit

Permalink
add: is active parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
justRkive committed Aug 15, 2024
1 parent fc2aba1 commit 9c88861
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/async_resolver/server_entry.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
use crate::async_resolver::server_info::ServerInfo;

/// Struct that holds the state of a single server for a request.
#[derive(Clone)]
pub struct ServerEntry {
info: ServerInfo,
retransmissions: u32,
is_active: bool,
}

impl ServerEntry {
pub fn new(info: ServerInfo) -> ServerEntry {
ServerEntry {
info,
retransmissions: 0,
is_active: true,
}
}

pub fn get_info(&self) -> &ServerInfo {
&self.info
&self.info// TODO: see if this is necessary to use clone or not, in order to reuse TCP connections
}

pub fn get_retransmissions(&self) -> u32 {
Expand All @@ -29,4 +32,12 @@ impl ServerEntry {
pub fn reset_retransmissions(&mut self) {
self.retransmissions = 0;
}

pub fn is_active(&self) -> bool {
self.is_active
}

pub fn set_active(&mut self, is_active: bool) {
self.is_active = is_active;
}
}

0 comments on commit 9c88861

Please sign in to comment.