Skip to content

Commit

Permalink
Fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
VianneyRuhlmann committed Sep 11, 2024
1 parent ee7ad63 commit 543db99
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 3 additions & 0 deletions agent-info/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ edition.workspace = true
version.workspace = true
license.workspace = true

[lib]
bench = false

[dependencies]
anyhow = "1.0.86"
arc-swap = "1.7.1"
Expand Down
13 changes: 7 additions & 6 deletions agent-info/src/fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ async fn fetch_info_with_state(

/// Fetch the info endpoint once and return the info.
///
/// Can be used for one-time access to the agent's info. If you need to access the info over
/// long period use `AgentInfoFetcher` to keep the info up-to-date.
/// Can be used for one-time access to the agent's info. If you need to access the info several
/// times use `AgentInfoFetcher` to keep the info up-to-date.
///
/// # Example
/// ```no_run
Expand All @@ -78,7 +78,7 @@ pub async fn fetch_info(info_endpoint: &Endpoint) -> Result<Box<AgentInfo>> {
}
}

/// Fetch the info endpoint and update an ArcSwap based on a given time interval.
/// Fetch the info endpoint and update an ArcSwap keeping it up-to-date.
///
/// Once the fetcher has been created you can get an Arc of the config by calling `get_info`.
/// You can then start the run method, the fetcher will update the AgentInfoArc based on the
Expand Down Expand Up @@ -120,17 +120,18 @@ pub struct AgentInfoFetcher {
impl AgentInfoFetcher {
/// Return a new `AgentInfoFetcher` fetching the `info_endpoint` on each `refresh_interval`
/// and updating the stored info.
pub fn new(info_endpoint: Endpoint, fetch_interval: Duration) -> Self {
pub fn new(info_endpoint: Endpoint, refresh_interval: Duration) -> Self {
Self {
info_endpoint,
info: Arc::new(ArcSwapOption::new(None)),
refresh_interval: fetch_interval,
refresh_interval,
}
}

/// Start fetching the info endpoint with the given interval.
///
/// Warning: This method does not return and should be called within a dedicated task.
/// # Warning
/// This method does not return and should be called within a dedicated task.
pub async fn run(&self) {
loop {
let current_info = self.info.load();
Expand Down

0 comments on commit 543db99

Please sign in to comment.