这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@u5surf
Copy link
Owner

@u5surf u5surf commented Sep 12, 2025

Summary

This PR removes unused dead code from the codebase to improve maintainability and reduce confusion. The removed code was marked with #[allow(dead_code)] but was not actually used anywhere in the project.

Removed Dead Code

  • ngx_http_vts_log_handler(): Unused LOG_PHASE handler function
  • collect_upstream_request_stats(): Unused helper function for upstream statistics collection
  • VtsMainConfig: Unused configuration structure and its implementation

Why These Were Dead Code

  • The actual LOG_PHASE handling is implemented in src/ngx_vts_wrapper.c which calls the Rust vts_track_upstream_request() function
  • These Rust functions were planned for direct nginx FFI integration but are not used in the current architecture
  • The functions contained hardcoded values and simplified logic that would not work in production

Benefits

  • Cleaner codebase: Eliminates confusing unused code paths
  • Reduced maintenance overhead: Less code to maintain and understand
  • Binary size reduction: Slightly smaller compiled output
  • Better code clarity: Developers won't be confused by unused functions

Testing

  • All 40 unit tests continue to pass
  • cargo clippy --all-targets --all-features -- -D warnings passes with no warnings
  • No functional changes - only dead code removal

Impact

This is a safe cleanup change with no functional impact. The removed code was never called or used, so there are no breaking changes or behavioral modifications.

🤖 Generated with Claude Code

u5surf and others added 3 commits September 12, 2025 18:12
Removed unused functions and structures that were not actually used:

- ngx_http_vts_log_handler(): Unused LOG_PHASE handler (actual implementation is in C wrapper)
- collect_upstream_request_stats(): Unused helper function for the above handler
- VtsMainConfig struct and its implementation: Unused configuration structure

These functions were marked with #[allow(dead_code)] but were not actually used
anywhere in the codebase. The actual LOG_PHASE handling is implemented in
src/ngx_vts_wrapper.c which calls the Rust vts_track_upstream_request() function.

Benefits:
- Cleaner codebase with reduced maintenance overhead
- Eliminates potentially confusing unused code paths
- Reduces binary size slightly
- All tests continue to pass (40 passed; 0 failed)
- No clippy warnings introduced

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove unused UpstreamStatsCollector struct and implementation
- Remove unused UpstreamRequestData struct and implementation
- Remove global variables for upstream stats collection
- Remove unused nginx integration functions
- Remove corresponding test functions for dead code
- Clean up unused imports (Arc, RwLock, nginx FFI types)

All remaining tests (34) pass successfully with no clippy warnings.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@u5surf u5surf requested a review from Copilot September 13, 2025 00:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes unused dead code from the Rust VTS module to improve maintainability and reduce confusion. The removed components were marked with #[allow(dead_code)] but were not actually utilized in the current architecture.

  • Removes ngx_http_vts_log_handler() and collect_upstream_request_stats() functions that were planned for direct nginx FFI integration but are unused
  • Removes UpstreamStatsCollector, UpstreamRequestData, and related infrastructure that duplicates existing functionality
  • Removes VtsMainConfig structure that was not integrated into the configuration system

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/upstream_stats.rs Removes unused upstream statistics collection infrastructure and associated test cases
src/lib.rs Removes unused LOG_PHASE handler function, helper function, and configuration structure

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

//! byte transfers, response times, and server status information.
use ngx::ffi::{ngx_http_request_t, ngx_int_t, NGX_ERROR, NGX_OK};
use std::collections::HashMap;
Copy link

Copilot AI Sep 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HashMap import is no longer used after removing the UpstreamStatsCollector and related code. This unused import should be removed to maintain code cleanliness.

Copilot uses AI. Check for mistakes.
// For now, this is a placeholder

Ok(())
}
Copy link

Copilot AI Sep 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The file appears to end abruptly after the test module. Consider adding a newline at the end of the file to follow standard formatting conventions.

Copilot uses AI. Check for mistakes.
@u5surf u5surf merged commit eaf2dde into main Sep 13, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants