Thank you for your interest in contributing to Rust Service Mesh! This document provides guidelines for contributing to the project.
Be respectful, inclusive, and professional. We're all here to build great software together.
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/Rust-ServiceMesh.git cd Rust-ServiceMesh - Create a branch for your changes:
git checkout -b feature/my-awesome-feature
- Rust 1.75 or later
- Cargo
- Git
# Debug build
cargo build
# Release build
cargo build --releaseAll contributions must include tests and pass existing tests:
# Run all tests
cargo test
# Run tests for a specific module
cargo test circuit_breaker
# Run with logging
RUST_LOG=debug cargo test
# Run clippy (required)
cargo clippy --all-features -- -D warnings
# Format code (required)
cargo fmt- Follow standard Rust conventions (enforced by
rustfmt) - Run
cargo fmtbefore committing - All code must pass
cargo clippy --all-features -- -D warnings - Use meaningful variable and function names
- Keep functions under 100 lines when possible
- Add
///doc comments to all public items - Include examples in doc comments for complex APIs
- Update README.md if adding user-facing features
- Doc tests should compile (
cargo test --doc)
- Use
Resulttypes, avoid panics in library code - Provide context in error messages
- Use
thiserrorfor error types
- Write unit tests for all new functionality
- Add integration tests for end-to-end scenarios
- Aim for >80% code coverage
- Test error paths, not just happy paths
- Profile performance-critical code
- Avoid unnecessary allocations
- Use
Arcfor shared state, avoidMutexwhen possible - Prefer lock-free atomics for counters
-
Ensure your code passes all checks:
cargo fmt --check cargo clippy --all-features -- -D warnings cargo test --all cargo build --release -
Update documentation:
- Add/update doc comments
- Update README.md if needed
- Add examples if introducing new features
-
Write a clear PR description:
- Explain what changes you made and why
- Reference any related issues
- Include before/after behavior if applicable
-
Commit message format:
type: brief description Longer explanation if needed. Fixes #123Types:
feat,fix,docs,refactor,test,perf,chore -
Submit the PR:
- Push to your fork
- Open a PR against
main - Respond to review feedback
- Retry logic with exponential backoff
- Connection pooling in Transport module
- Rate limiting middleware
- Health checking for upstreams
- Additional integration tests
- Distributed tracing (OpenTelemetry)
- Advanced load balancing algorithms
- L7 routing implementation
- HTTP/2 support
- Benchmarking suite
- mTLS support
- gRPC proxying
- WASM filter support
- Kubernetes sidecar mode
- Keep modules focused and single-purpose
- Use
pub(crate)for internal APIs - Expose minimal public surface area
- Group related functionality
- Use Tokio for async runtime
- Avoid blocking operations in async contexts
- Use
tokio::spawnfor CPU-intensive work - Prefer
tokio::select!over manual polling
- Justify new dependencies in your PR
- Prefer well-maintained crates
- Check licenses (Apache-2.0 or MIT compatible)
- Run
cargo auditto check for vulnerabilities
// Good: Contextual errors
.map_err(|e| ProxyError::ListenerBind {
addr: addr.to_string(),
source: e,
})?
// Bad: Generic errors
.map_err(|e| format!("Error: {}", e))?// Use tracing macros
use tracing::{debug, info, warn, error, instrument};
#[instrument(level = "debug", skip(self))]
async fn my_function(&self) {
info!("Starting operation");
debug!(param = ?value, "Processing");
}- Open an issue for bugs or feature requests
- Start a discussion for design questions
- Check existing issues before creating new ones
By contributing, you agree that your contributions will be dual-licensed under both the MIT License and Apache License 2.0, at the user's option.
Thank you for contributing to Rust Service Mesh!