src/events/ module provides a lightweight, in-process event bus.
Architecture
Key Files
Overview
The events system provides:- Real-time event emission for repository activities
- Handler registration for processing events
- Integration with notifications, CI, and webhooks
- Extensibility for custom event handling
- Event logging for debugging
Event Types
Repository Events
Push Events
Pull Request Events
Issue Events
CI Events
Mention Events
Merge Queue Events
Event Bus
The central event bus manages event emission and handler registration.Emitting Events
Subscribing to Events
Built-in Handlers
Notification Handler
Automatically creates notifications for relevant events:- PR comments and reviews
- Mentions in comments
- Review requests
- Issue assignments
- Access grants
CI Handler
Triggers CI workflows based on events:- Push events
- PR opened/synchronized
- Manual workflow dispatch
Merge Queue Handler
Processes merge queue state changes:Event Structure
All events follow a common structure:Example Events
Push Event:Custom Event Handlers
Creating a Handler
Handler with Filtering
Error Handling
Helper Functions
Extracting Mentions
Creating Events
Integration Points
Webhooks
Events are automatically sent to configured webhooks:Activity Feed
Events populate the activity feed:Real-time Updates
Events can be sent to connected clients:Testing Event Handlers
Best Practices
- Keep handlers fast - Long-running operations should be queued
- Handle errors gracefully - Don’t let one handler break others
- Use specific events - Subscribe to specific types when possible
- Idempotency - Design handlers to be safely re-run
- Logging - Log event processing for debugging
Related
- Webhooks API - Configure webhooks
- Notifications API - Notification system
- CI/CD - CI/CD integration