Skip to content

Commit 170ce02

Browse files
committed
refactor: [#255] extract conflict checking logic into separate method
- Extract check_for_conflicts() private method from validate() - Further improves Single Responsibility Principle - Now validate() is a clean orchestrator of two focused methods - Three-level separation: collect → check → report error
1 parent 97368e5 commit 170ce02

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

  • src/domain/tracker/config

src/domain/tracker/config/mod.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,21 @@ impl TrackerConfig {
211211
/// ```
212212
pub fn validate(&self) -> Result<(), TrackerConfigError> {
213213
let bindings = self.collect_bindings();
214+
Self::check_for_conflicts(bindings)
215+
}
214216

215-
// Check for duplicates
217+
/// Checks for socket address conflicts in the collected bindings
218+
///
219+
/// Examines the binding map to find any addresses that have multiple
220+
/// services attempting to use them with the same protocol.
221+
///
222+
/// # Errors
223+
///
224+
/// Returns `TrackerConfigError::DuplicateSocketAddress` if any binding
225+
/// address is shared by multiple services.
226+
fn check_for_conflicts(
227+
bindings: HashMap<BindingAddress, Vec<String>>,
228+
) -> Result<(), TrackerConfigError> {
216229
for (binding, services) in bindings {
217230
if services.len() > 1 {
218231
return Err(TrackerConfigError::DuplicateSocketAddress {

0 commit comments

Comments
 (0)