-
Notifications
You must be signed in to change notification settings - Fork 11
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
Conversation
Co-authored-by: Simon Hornby <sighphyre@users.noreply.github.com> Co-authored-by: Gastón Fournier <gaston@getunleash.ai>
There was a problem hiding this 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>> { |
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
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
There was a problem hiding this 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!
Add
send_metrics_task
to our running tasks. It accepts a new arg:metrics_interval_seconds
.Rename
get_valid_tokens
tofilter_valid_tokens
to better reflect its behaviour. Addget_valid_tokens
to return all valid tokens from our store.Implement
background_send_metrics
.