Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

task: client metrics start task #51

Merged
merged 1 commit into from
Feb 9, 2023

Conversation

nunogois
Copy link
Member

@nunogois nunogois commented Feb 8, 2023

Add send_metrics_task to our running tasks. It accepts a new arg: metrics_interval_seconds.

Rename get_valid_tokens to filter_valid_tokens to better reflect its behaviour. Add get_valid_tokens to return all valid tokens from our store.

Implement background_send_metrics.

Co-authored-by: Simon Hornby <sighphyre@users.noreply.github.com>
Co-authored-by: Gastón Fournier <gaston@getunleash.ai>
Copy link
Member

@chriswk chriswk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Nice work Nuno. @sighphyre have a look as well would you?

@@ -30,6 +30,15 @@ impl TokenSource for OfflineProvider {
Ok(self.valid_tokens.values().cloned().collect())
}

async fn get_valid_tokens(&self) -> EdgeResult<Vec<EdgeToken>> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idle thoughts but it looks like we might end up writing this same method over and over. Might be worth implementing this as a trait on Vec<EdgeToken>. Not something for this PR

}
}

tokio::time::sleep(Duration::from_secs(send_interval)).await;
}
}

async fn get_first_token(source: Arc<RwLock<dyn EdgeSource>>) -> EdgeResult<EdgeToken> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also idle thoughts, but if this feels like it wants to be an option not a result. Doesn't need to be done in this PR

Copy link
Member

@sighphyre sighphyre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this looks really clean!

@sighphyre sighphyre merged commit bf2bd81 into task-client-metrics Feb 9, 2023
@sighphyre sighphyre deleted the task-client-metrics-start-task branch February 9, 2023 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants