Skip to content

Commit

Permalink
docs: server entry add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
justRkive committed Dec 1, 2024
1 parent d2761a5 commit d7fb9c1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/async_resolver/server_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,34 @@ use crate::async_resolver::server_info::ServerInfo;
/// Struct that holds the state of a single server for a request.
#[derive(Clone)]
pub struct ServerEntry {
/// Information about the server.
info: ServerInfo,
/// The work counter to limit the amount of work done on a single server.
///
/// If the counter reaches zero, the resolver must return a response to the client.
work_counter: u16,
}

impl ServerEntry {
/// Creates a new ServerEntry for a request.
pub fn new(info: ServerInfo, work_counter: u16) -> ServerEntry {
ServerEntry {
info,
work_counter: work_counter,
}
}

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

/// Returns the work counter of the server.
pub fn get_work_counter(&self) -> u16 {
self.work_counter
}

/// Decrements the work counter of the server.
pub fn decrement_work_counter(&mut self) {
self.work_counter -= 1;
}
Expand Down

0 comments on commit d7fb9c1

Please sign in to comment.