We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:
- Reporting a bug
- Discussing the current state of the code
- Submitting a fix
- Proposing new features
- Becoming a maintainer
We use GitHub to host code, to track issues and feature requests, as well as accept pull requests.
Pull requests are the best way to propose changes to the codebase. We actively welcome your pull requests:
- Fork the repo and create your branch from
main. - If you've added code that should be tested, add tests.
- If you've changed APIs, update the documentation.
- Ensure the test suite passes.
- Make sure your code lints.
- Issue that pull request!
- Go 1.24+
- Redis server
- Docker and Docker Compose (optional but recommended)
- Clone and setup:
git clone https://github.com/rosaboyle/sse-virtualization-layer.git
cd sse-virtualization-layer
cp .env.example .env- Install dependencies:
make deps- Start development environment:
make docker-compose-up # Starts Redis
make run # In another terminal- Run tests:
make test- Follow standard Go formatting (
go fmt) - Use meaningful variable and function names
- Add comments for complex logic
- Keep functions focused and small
- Follow Go best practices and idioms
- Write unit tests for new functionality
- Ensure existing tests pass
- Add integration tests for new endpoints
- Test both success and error scenarios
- Update README.md for user-facing changes
- Add/update code comments for complex logic
- Update API documentation for endpoint changes
- Include examples for new features
main- Production-ready codedevelop- Integration branch for featuresfeature/feature-name- New featuresbugfix/bug-description- Bug fixeshotfix/critical-fix- Critical production fixes
Use clear and meaningful commit messages:
feat: add function timeout configuration
fix: resolve SSE connection drops on idle
docs: update API documentation
test: add unit tests for connection manager
refactor: improve error handling in gateway
feature/add-metrics-endpointbugfix/fix-memory-leakdocs/update-api-docstest/add-integration-tests
Great Bug Reports tend to have:
- A quick summary and/or background
- Steps to reproduce
- Be specific!
- Give sample code if you can
- What you expected would happen
- What actually happens
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)
Feature requests should include:
- Clear description of the feature
- Use case and motivation
- Detailed behavior description
- Any alternative solutions considered
pkg/
├── config/ # Configuration management
├── types/ # Shared data structures
├── redis/ # Redis client and operations
├── manager/ # Connection management
├── registry/ # Function registry
└── gateway/ # SSE gateway logic
- Separation of Concerns: Each package has a single responsibility
- Dependency Injection: Use interfaces for testability
- Error Handling: Explicit error handling with context
- Concurrency: Use Go routines safely with proper synchronization
- Performance: Optimize for high throughput and low latency
- RESTful endpoints where appropriate
- Consistent naming conventions
- Proper HTTP status codes
- JSON request/response format
- Comprehensive error messages
func TestConnectionManager_AddConnection(t *testing.T) {
// Setup
cm := NewConnectionManager(mockRedisClient)
// Execute
conn := cm.AddConnection("client1", "user1", nil)
// Assert
assert.NotNil(t, conn)
assert.Equal(t, "client1", conn.ClientID)
}func TestSSEGateway_HandleConnection(t *testing.T) {
// Setup test server
server := httptest.NewServer(handler)
defer server.Close()
// Test SSE connection
// ...
}- Benchmark critical paths
- Test concurrent connections
- Measure memory usage
- Profile CPU usage
- Validate all input data
- Use HTTPS in production
- Implement rate limiting
- Sanitize log output
- Follow OWASP guidelines
// ConnectionManager manages SSE connections and their lifecycle.
// It provides thread-safe operations for adding, removing, and
// broadcasting messages to active connections.
type ConnectionManager struct {
connections map[string]*types.Connection
mutex sync.RWMutex
redisClient *redis.Client
}
// AddConnection creates a new SSE connection and stores it in Redis.
// Returns the created connection or error if storage fails.
func (cm *ConnectionManager) AddConnection(clientID, userID string, metadata map[string]string) (*types.Connection, error) {
// Implementation...
}Document all endpoints with:
- Purpose and use case
- Request/response format
- Error conditions
- Example usage
- Connection Scaling: Efficient connection management
- Memory Usage: Minimize allocations in hot paths
- Redis Operations: Batch operations where possible
- Goroutine Management: Proper lifecycle management
- HTTP Performance: Connection pooling and keep-alive
- Add metrics for key operations
- Log performance-critical events
- Monitor memory and CPU usage
- Track connection lifecycle
We use Semantic Versioning:
- MAJOR.MINOR.PATCH
- MAJOR: incompatible API changes
- MINOR: backwards-compatible functionality
- PATCH: backwards-compatible bug fixes
- All tests pass
- Documentation updated
- Changelog updated
- Version bumped
- Tagged release
- Docker image published
- Create an issue for bugs or feature requests
- Join our discussions for questions
- Check existing documentation first
- Provide minimal reproducible examples
By contributing, you agree that your contributions will be licensed under the same license as the project (MIT License).
Contributors will be recognized in:
- CONTRIBUTORS.md file
- Release notes
- Project documentation
Thank you for contributing! 🚀