Contributing to drogue¶
Development Setup¶
Prerequisites¶
- Python 3.10+
- pip
- git
Clone and Install¶
Verify Installation¶
Project Structure¶
drogue/
├── src/drogue/
│ ├── core/ # Core engine
│ │ ├── abstracts.py # Abstract base classes
│ │ ├── algorithms/ # Rate limit algorithms
│ │ ├── config.py # Configuration
│ │ ├── errors.py # Exceptions
│ │ ├── headers.py # Response headers
│ │ ├── identity/ # Identity extractors
│ │ ├── rules/ # Rule parsing
│ │ └── storage/ # Storage backends
│ ├── adapters/ # Framework adapters
│ │ ├── fastapi/
│ │ ├── django/
│ │ └── flask/
│ ├── protection/ # Protection layer
│ │ ├── ban.py # Progressive auto-ban
│ │ ├── ddos.py # DDoS detection
│ │ ├── trust.py # Trust state machine
│ │ ├── sentinel.py # Half-Space Trees
│ │ ├── probes.py # Probe detection
│ │ ├── cidr.py # CIDR filtering
│ │ └── adaptive.py # Adaptive rate limiting
│ ├── defense/ # Defense mechanisms
│ │ └── randomizer.py # Defense randomization
│ ├── storage/ # Advanced storage
│ │ └── probabilistic.py
│ └── observability/ # Observability
│ └── opentelemetry.py
├── tests/ # Test suite
├── examples/ # Usage examples
├── docs/ # Documentation
└── pyproject.toml
Code Style¶
Formatting¶
- Line length: 100 characters
- Use double quotes for strings
- Use trailing commas in collections
Linting¶
Type Hints¶
All code must have complete type hints:
Docstrings¶
Use Google-style docstrings:
def record(self, client_key: str) -> None:
"""Record a request for a client.
Args:
client_key: The client identifier.
"""
...
Adding a New Feature¶
1. Create a Branch¶
2. Write Tests First¶
# tests/test_my_feature.py
import pytest
async def test_my_feature():
# Arrange
feature = MyFeature()
# Act
result = await feature.do_something()
# Assert
assert result == expected
3. Implement the Feature¶
Follow existing patterns in the codebase.
4. Run Tests¶
5. Run Linter¶
6. Create a Pull Request¶
- Describe what the PR does
- Reference any related issues
- Include tests for new functionality
Testing¶
Unit Tests¶
With Coverage¶
Specific Test¶
Integration Tests¶
Documentation¶
Build Docs¶
View Docs¶
Open http://localhost:8000 in your browser.
Release Process¶
- Update version in
pyproject.toml - Update
docs/development/changelog.md - Create a git tag
- Push to GitHub
- Create a release on GitHub
Questions?¶
Open an issue at https://github.com/Zlynv/drogue/issues