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

Request IDs #2054

Merged
merged 20 commits into from Dec 22, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -5,10 +5,9 @@

use std::net::{IpAddr, SocketAddr};

use aws_smithy_http_server::{
request::connect_info::ConnectInfo, request::request_id::ServerRequestId,
request::request_id::ServerRequestIdProviderLayer,
};
use aws_smithy_http_server::request::connect_info::ConnectInfo;
#[cfg(feature = "request-id")]
LukeMathWalker marked this conversation as resolved.
Show resolved Hide resolved
use aws_smithy_http_server::{request::request_id::ServerRequestId, request::request_id::ServerRequestIdProviderLayer};
use clap::Parser;
use pokemon_service::{capture_pokemon, check_health, get_pokemon_species, get_server_statistics, setup_tracing};
use pokemon_service_server_sdk::{
Expand Down Expand Up @@ -56,13 +55,15 @@ pub async fn get_storage_with_local_approved(
Err(GetStorageError::NotAuthorized(NotAuthorized {}))
}

pub async fn do_nothing_but_log_request_ids(
_input: DoNothingInput,
server_request_id: ServerRequestId,
) -> DoNothingOutput {
#[cfg(feature = "request-id")]
pub async fn do_nothing(_input: DoNothingInput, server_request_id: ServerRequestId) -> DoNothingOutput {
tracing::debug!("This request has this server ID: {}", server_request_id);
DoNothingOutput {}
}
#[cfg(not(feature = "request-id"))]
pub async fn do_nothing(_input: DoNothingInput) -> DoNothingOutput {
DoNothingOutput {}
}

#[tokio::main]
async fn main() {
Expand All @@ -73,11 +74,12 @@ async fn main() {
.get_storage(get_storage_with_local_approved)
.get_server_statistics(get_server_statistics)
.capture_pokemon(capture_pokemon)
.do_nothing(do_nothing_but_log_request_ids)
.do_nothing(do_nothing)
.check_health(check_health)
.build()
.expect("failed to build an instance of PokemonService");

#[cfg(feature = "request-id")]
let app = app.layer(&ServerRequestIdProviderLayer::new());

// Start the [`hyper::Server`].
Expand Down