-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconstants.rs
More file actions
59 lines (55 loc) · 2.54 KB
/
constants.rs
File metadata and controls
59 lines (55 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! Constants for command handlers
//!
//! This module provides centralized configuration constants used across command handlers.
//! These constants help eliminate duplicate magic numbers and make configuration explicit.
//!
//! ## Constants
//!
//! - [`DEFAULT_LOCK_TIMEOUT`]: Default timeout for file lock operations in repository
//! - [`DEFAULT_VERBOSITY`]: Default verbosity level for user output
//!
//! ## Benefits
//!
//! - Eliminates duplicate magic numbers across command handlers
//! - Makes configuration values explicit and discoverable
//! - Easier to adjust behavior without searching through code
//! - Better documentation for why specific values are used
//!
//! ## Usage Example
//!
//! ```rust
//! use torrust_tracker_deployer_lib::presentation::cli::controllers::constants::{DEFAULT_LOCK_TIMEOUT, DEFAULT_VERBOSITY};
//! use torrust_tracker_deployer_lib::infrastructure::persistence::file_repository_factory::FileRepositoryFactory;
//! use torrust_tracker_deployer_lib::presentation::cli::views::UserOutput;
//!
//! // Use default lock timeout for repository operations
//! let file_repository_factory = FileRepositoryFactory::new(DEFAULT_LOCK_TIMEOUT);
//!
//! // Use default verbosity for user output
//! let mut output = UserOutput::new(DEFAULT_VERBOSITY);
//! ```
use std::time::Duration;
use crate::presentation::cli::views::VerbosityLevel;
/// Default timeout for file lock operations in repository
///
/// This timeout is used when acquiring file locks during repository operations
/// to prevent indefinite blocking. A 30-second timeout provides a balance between:
///
/// - Allowing sufficient time for legitimate operations to complete
/// - Preventing indefinite hangs in case of issues
/// - Providing reasonable user experience (users won't wait forever)
///
/// This value is used across all command handlers that interact with the repository.
pub const DEFAULT_LOCK_TIMEOUT: Duration = Duration::from_secs(30);
/// Default verbosity level for user output
///
/// This verbosity level is used as the default for user-facing output across all commands.
/// `VerbosityLevel::Normal` provides essential progress and results without overwhelming
/// users with details, making it suitable for typical command execution.
///
/// Users can override this default through command-line flags if they need:
/// - Less output (Quiet) for automation/scripting
/// - More output (Verbose/Debug) for troubleshooting
///
/// This value is used across all command handlers for consistent user experience.
pub const DEFAULT_VERBOSITY: VerbosityLevel = VerbosityLevel::Normal;