Skip to content

Remove unnecessary mut #2219

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

Merged
merged 3 commits into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/src/health/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Greeter for MyGreeter {

/// This function (somewhat improbably) flips the status of a service every second, in order
/// that the effect of `tonic_health::HealthReporter::watch` can be easily observed.
async fn twiddle_service_status(mut reporter: HealthReporter) {
async fn twiddle_service_status(reporter: HealthReporter) {
let mut iter = 0u64;
loop {
iter += 1;
Expand All @@ -45,7 +45,7 @@ async fn twiddle_service_status(mut reporter: HealthReporter) {

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let (mut health_reporter, health_service) = tonic_health::server::health_reporter();
let (health_reporter, health_service) = tonic_health::server::health_reporter();
health_reporter
.set_serving::<GreeterServer<MyGreeter>>()
.await;
Expand Down
8 changes: 4 additions & 4 deletions tonic-health/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl HealthReporter {

/// Sets the status of the service implemented by `S` to `Serving`. This notifies any watchers
/// if there is a change in status.
pub async fn set_serving<S>(&mut self)
pub async fn set_serving<S>(&self)
where
S: NamedService,
{
Expand All @@ -59,7 +59,7 @@ impl HealthReporter {

/// Sets the status of the service implemented by `S` to `NotServing`. This notifies any watchers
/// if there is a change in status.
pub async fn set_not_serving<S>(&mut self)
pub async fn set_not_serving<S>(&self)
where
S: NamedService,
{
Expand All @@ -70,7 +70,7 @@ impl HealthReporter {

/// Sets the status of the service with `service_name` to `status`. This notifies any watchers
/// if there is a change in status.
pub async fn set_service_status<S>(&mut self, service_name: S, status: ServingStatus)
pub async fn set_service_status<S>(&self, service_name: S, status: ServingStatus)
where
S: AsRef<str>,
{
Expand Down Expand Up @@ -220,7 +220,7 @@ mod tests {

#[tokio::test]
async fn test_service_check() {
let (mut reporter, service) = make_test_service().await;
let (reporter, service) = make_test_service().await;

// Overall server health
let resp = service
Expand Down