From 4aff0f779ed0d6221969e52c443b5df7be36107e Mon Sep 17 00:00:00 2001 From: Heiko Seeberger Date: Tue, 23 Jul 2024 11:32:51 +0200 Subject: [PATCH] refactor: some renaming (#109) --- .../proto/hello-tracing-backend-v0.proto | 2 +- hello-tracing-backend/src/api/v0.rs | 10 +++++----- .../proto/hello-tracing-backend-v0.proto | 2 +- hello-tracing-gateway/src/backend.rs | 12 ++++++------ 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/hello-tracing-backend/proto/hello-tracing-backend-v0.proto b/hello-tracing-backend/proto/hello-tracing-backend-v0.proto index 0c3eea7..19ed2b3 100644 --- a/hello-tracing-backend/proto/hello-tracing-backend-v0.proto +++ b/hello-tracing-backend/proto/hello-tracing-backend-v0.proto @@ -5,4 +5,4 @@ service Hello { rpc Hello(HelloRequest) returns (HelloResponse); } message HelloRequest {} -message HelloResponse { string msg = 1; } +message HelloResponse { string message = 1; } diff --git a/hello-tracing-backend/src/api/v0.rs b/hello-tracing-backend/src/api/v0.rs index 2bc26b6..1e612d2 100644 --- a/hello-tracing-backend/src/api/v0.rs +++ b/hello-tracing-backend/src/api/v0.rs @@ -10,7 +10,7 @@ use std::sync::atomic::{AtomicBool, Ordering}; use tonic::{Request, Response, Status}; use tracing::{debug, instrument}; -const MSGS: [&str; 2] = [ +const MESSAGES: [&str; 2] = [ "Hello, I'm a tracing demo!", "Hello, I'm built with Rust, Axum and tonic!", ]; @@ -34,10 +34,10 @@ impl Hello for HelloService { self.0.store(current, Ordering::Release); // Get message for this response. - let msg = if current { MSGS[0] } else { MSGS[1] }; - let msg = msg.to_string(); - debug!(msg, "answering with msg"); + let message = if current { MESSAGES[0] } else { MESSAGES[1] }; + let message = message.to_string(); + debug!(message, "answering"); - Ok(Response::new(HelloResponse { msg })) + Ok(Response::new(HelloResponse { message })) } } diff --git a/hello-tracing-gateway/proto/hello-tracing-backend-v0.proto b/hello-tracing-gateway/proto/hello-tracing-backend-v0.proto index 0c3eea7..19ed2b3 100644 --- a/hello-tracing-gateway/proto/hello-tracing-backend-v0.proto +++ b/hello-tracing-gateway/proto/hello-tracing-backend-v0.proto @@ -5,4 +5,4 @@ service Hello { rpc Hello(HelloRequest) returns (HelloResponse); } message HelloRequest {} -message HelloResponse { string msg = 1; } +message HelloResponse { string message = 1; } diff --git a/hello-tracing-gateway/src/backend.rs b/hello-tracing-gateway/src/backend.rs index 4d643da..72180ac 100644 --- a/hello-tracing-gateway/src/backend.rs +++ b/hello-tracing-gateway/src/backend.rs @@ -31,20 +31,20 @@ impl Backend { .with_context(|| format!("connect to endpoint {}", self.endpoint))?; let mut client = HelloClient::with_interceptor(channel, send_trace); - let msg = client + let message = client .hello(HelloRequest {}) .await - .with_context(|| format!("call rpc Hello on endpoint {}", self.endpoint))? + .with_context(|| format!("call Hello on endpoint {}", self.endpoint))? .into_inner() - .msg; + .message; debug!( - msg, + message, endpoint = self.endpoint, - "received response from rpc Hello" + "received response from Hello" ); - Ok(msg) + Ok(message) } }