Skip to content

Commit

Permalink
refactor(api): add config::app module
Browse files Browse the repository at this point in the history
  • Loading branch information
ymgyt committed Sep 2, 2024
1 parent 324a76b commit a1fc295
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions crates/synd_api/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
pub const USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"));

pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const NAME: &str = env!("CARGO_PKG_NAME");
pub mod app {
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const NAME: &str = env!("CARGO_PKG_NAME");
}

pub const PORT: u16 = 5959;

Expand Down
6 changes: 3 additions & 3 deletions crates/synd_api/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ fn init_tracing(options: &ObservabilityOptions) -> Option<OpenTelemetryGuard> {
.map(|endpoint| {
synd_o11y::opentelemetry_layer(
endpoint,
config::NAME,
config::VERSION,
config::app::NAME,
config::app::VERSION,
options.trace_sampler_ratio,
)
}) {
Expand Down Expand Up @@ -92,7 +92,7 @@ async fn run(
.await?;

info!(
version = config::VERSION,
version = config::app::VERSION,
otlp_endpoint=?o11y.otlp_endpoint,
request_timeout=?dep.serve_options.timeout,
request_body_limit_bytes=dep.serve_options.body_limit_bytes,
Expand Down
2 changes: 1 addition & 1 deletion crates/synd_api/src/serve/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub async fn healthcheck() -> impl IntoResponse {
[(header::CONTENT_TYPE, Health::CONTENT_TYPE)],
Json(
Health::pass()
.with_version(config::VERSION)
.with_version(config::app::VERSION)
.with_description("health of synd-api"),
),
)
Expand Down

0 comments on commit a1fc295

Please sign in to comment.