-
-
Notifications
You must be signed in to change notification settings - Fork 292
Add GitHub Copilot instructions #748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| # GitHub Copilot Instructions for oha | ||
|
|
||
| ## Project Overview | ||
|
|
||
| `oha` (おはよう) is a HTTP load testing tool written in Rust, inspired by `rakyll/hey`. It provides real-time TUI (Terminal User Interface) visualization of load testing results using `ratatui`. | ||
|
|
||
| ## Key Technologies & Dependencies | ||
|
|
||
| - **Language**: Rust (edition 2024, MSRV 1.85) | ||
| - **Async Runtime**: `tokio` with full features | ||
| - **HTTP Client**: `hyper` (v1.4) with HTTP/1, HTTP/2 support | ||
| - **TUI**: `ratatui` with `crossterm` backend | ||
| - **CLI**: `clap` with derive features | ||
| - **Memory Allocator**: `tikv-jemallocator` (non-MSVC targets) | ||
| - **Error Handling**: `anyhow` and `thiserror` | ||
| - **JSON**: `serde` and `serde_json` | ||
| - **Database**: `rusqlite` with bundled SQLite | ||
| - **Networking**: `hickory-resolver` for DNS resolution | ||
|
|
||
| ## Project Structure | ||
|
|
||
| ``` | ||
| src/ | ||
| ├── lib.rs # Main library with CLI definitions and core logic | ||
| ├── main.rs # Binary entry point | ||
| ├── client.rs # HTTP client implementations (HTTP/1, HTTP/2) | ||
| ├── client_h3.rs # HTTP/3 client (feature-gated) | ||
| ├── aws_auth.rs # AWS signature authentication | ||
| ├── db.rs # Database operations for storing results | ||
| ├── histogram.rs # Statistical histogram implementation | ||
| ├── monitor.rs # Real-time monitoring and TUI | ||
| ├── printer.rs # Output formatting and display | ||
| ├── result_data.rs # Data structures for test results | ||
| ├── timescale.rs # Time-based scaling utilities | ||
| ├── tls_config.rs # TLS configuration | ||
| ├── url_generator.rs # URL generation with patterns | ||
| └── pcg64si.rs # Random number generation | ||
| ``` | ||
|
|
||
| ## Features & Build Configurations | ||
|
|
||
| ### Default Features | ||
| - `rustls` - Uses rustls for TLS (default) | ||
|
|
||
| ### Optional Features | ||
| - `native-tls` - Use native TLS instead of rustls | ||
| - `vsock` - Enable VSOCK support for VM communication | ||
| - `http3` - Experimental HTTP/3 support via `h3` library | ||
|
|
||
| ### Build Examples | ||
| ```bash | ||
| # Default build with rustls | ||
| cargo build | ||
|
|
||
| # With native TLS | ||
| cargo build --no-default-features --features native-tls | ||
|
|
||
| # With HTTP/3 support | ||
| cargo build --features http3 | ||
|
|
||
| # With VSOCK support | ||
| cargo build --features vsock | ||
| ``` | ||
|
|
||
| ## Code Style & Conventions | ||
|
|
||
| ### Error Handling | ||
| - Use `anyhow::Result<T>` for functions that can fail | ||
| - Use `anyhow::bail!()` for early returns with error messages | ||
| - Use `anyhow::ensure!()` for validation with custom error messages | ||
| - Use `thiserror` for custom error types (when needed) | ||
|
|
||
| ### Async Code | ||
| - All async code uses `tokio` | ||
| - Use `tokio::spawn` for concurrent tasks | ||
| - Prefer `async/await` over manual future polling | ||
|
|
||
| ### CLI Structure | ||
| - Use `clap` derive macros for argument parsing | ||
| - Main configuration struct is typically in `lib.rs` | ||
| - Support both short and long argument forms | ||
|
|
||
| ### TUI Guidelines | ||
| - Use `ratatui` for all terminal UI components | ||
| - Handle terminal resize events | ||
| - Implement proper cleanup on exit | ||
| - Use `crossterm` for terminal control | ||
|
|
||
| ### HTTP Client Patterns | ||
| - Support HTTP/1.1, HTTP/2, and optionally HTTP/3 | ||
| - Handle connection pooling and reuse | ||
| - Implement proper timeout handling | ||
| - Support custom headers and authentication | ||
|
|
||
| ### Performance Considerations | ||
| - Use `jemalloc` allocator for better memory performance | ||
| - Leverage `tokio`'s async runtime efficiently | ||
| - Minimize allocations in hot paths | ||
| - Use streaming where appropriate for large responses | ||
| - Use PCG64SI PRNG (`pcg64si.rs`) for high-performance random number generation | ||
|
|
||
| ## Testing | ||
|
|
||
| ### Test Structure | ||
| - Integration tests in `tests/` directory | ||
| - Use `assert_cmd` for CLI testing | ||
| - Test server setup with `axum` and `axum-server` | ||
| - SSL/TLS testing with provided certificates | ||
|
|
||
| ### Test Data | ||
| - Test certificates: `tests/common/server.cert` and `tests/common/server.key` | ||
| - Common test utilities in `tests/common/mod.rs` | ||
|
|
||
| ## Development Guidelines | ||
|
|
||
| 1. **Cross-platform**: Ensure code works on Linux, macOS, and Windows | ||
| 2. **Feature gates**: Use appropriate feature gates for optional dependencies | ||
| 3. **Documentation**: Document public APIs with rustdoc comments | ||
| 4. **Performance**: Profile and optimize hot paths | ||
| 5. **Error messages**: Provide helpful, actionable error messages | ||
| 6. **CLI UX**: Follow Unix conventions for command-line tools | ||
|
|
||
| ## Dependencies to Prefer | ||
|
|
||
| - **HTTP**: `hyper` and `hyper-util` for HTTP client functionality | ||
| - **TLS**: `rustls` by default, `native-tls` as fallback | ||
| - **Async**: `tokio` ecosystem (`tokio-util`, `tokio-rustls`, etc.) | ||
| - **CLI**: `clap` for argument parsing | ||
| - **Serialization**: `serde` ecosystem | ||
| - **Random**: `rand` and `rand_core` for randomization needs | ||
| - **Time**: `chrono` for time handling | ||
|
|
||
| ## Platform-specific Code | ||
|
|
||
| - Use `#[cfg(unix)]` for Unix-specific features (like `rlimit`) | ||
| - Use `#[cfg(not(target_env = "msvc"))]` for non-MSVC Windows builds | ||
| - Handle platform differences in TLS and networking code appropriately | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.