rustapi_core/app/
production.rs1#[derive(Debug, Clone)]
9pub struct ProductionDefaultsConfig {
10 pub(super) service_name: String,
11 pub(super) version: Option<String>,
12 pub(super) tracing_level: tracing::Level,
13 pub(super) health_endpoint_config: Option<crate::health::HealthEndpointConfig>,
14 pub(super) enable_request_id: bool,
15 pub(super) enable_tracing: bool,
16 pub(super) enable_health_endpoints: bool,
17}
18
19impl ProductionDefaultsConfig {
20 pub fn new(service_name: impl Into<String>) -> Self {
22 Self {
23 service_name: service_name.into(),
24 version: None,
25 tracing_level: tracing::Level::INFO,
26 health_endpoint_config: None,
27 enable_request_id: true,
28 enable_tracing: true,
29 enable_health_endpoints: true,
30 }
31 }
32
33 pub fn version(mut self, version: impl Into<String>) -> Self {
35 self.version = Some(version.into());
36 self
37 }
38
39 pub fn tracing_level(mut self, level: tracing::Level) -> Self {
41 self.tracing_level = level;
42 self
43 }
44
45 pub fn health_endpoint_config(mut self, config: crate::health::HealthEndpointConfig) -> Self {
47 self.health_endpoint_config = Some(config);
48 self
49 }
50
51 pub fn request_id(mut self, enabled: bool) -> Self {
53 self.enable_request_id = enabled;
54 self
55 }
56
57 pub fn tracing(mut self, enabled: bool) -> Self {
59 self.enable_tracing = enabled;
60 self
61 }
62
63 pub fn health_endpoints(mut self, enabled: bool) -> Self {
65 self.enable_health_endpoints = enabled;
66 self
67 }
68}