Skip to content

Make fields on Timings private, expose total elapsed #68

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
Jul 23, 2024
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 Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/twirp-build/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "twirp-build"
version = "0.4.0"
version = "0.5.0"
authors = ["The blackbird team <support@github.com>"]
edition = "2021"
description = "Code generation for async-compatible Twirp RPC interfaces."
Expand Down
2 changes: 1 addition & 1 deletion crates/twirp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "twirp"
version = "0.4.0"
version = "0.5.0"
authors = ["The blackbird team <support@github.com>"]
edition = "2021"
description = "An async-compatible library for Twirp RPC in Rust."
Expand Down
15 changes: 10 additions & 5 deletions crates/twirp/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ pub async fn not_found_handler() -> Response<Body> {
#[derive(Debug, Clone, Copy)]
pub struct Timings {
// When the request started.
pub start: Instant,
start: Instant,
// When the request was received (headers and body).
pub request_received: Option<Instant>,
request_received: Option<Instant>,
// When the request body was parsed.
pub request_parsed: Option<Instant>,
request_parsed: Option<Instant>,
// When the response handler returned.
pub response_handled: Option<Instant>,
response_handled: Option<Instant>,
// When the response was written.
pub response_written: Option<Instant>,
response_written: Option<Instant>,
}

impl Timings {
Expand Down Expand Up @@ -234,6 +234,11 @@ impl Timings {
_ => None,
}
}

/// The total duration since the request started.
pub fn total_duration(&self) -> Duration {
self.start.elapsed()
}
}

#[cfg(test)]
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy