feat:(events) added events feedback#85
Open
ms3c wants to merge 1 commit into
Open
Conversation
MrishoLukamba
requested changes
Nov 11, 2025
| } | ||
| } | ||
|
|
||
| // ========== PUBLIC FEEDBACK API ========== |
Contributor
There was a problem hiding this comment.
These public feedback api should be in rpc not here, so in lib.rs pass the feedback manager handler to rpc also and then have rpc methods to these APIs.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Event Feedback System for Relay Server
Overview
This PR introduces a comprehensive event feedback system for the Vane relay server, providing real-time observability and programmatic notifications for all relay and swarm events. The system enables applications to subscribe to and react to relay operations such as circuit establishment, reservations, connections, and more.
Motivation
The relay server handles numerous P2P events (circuits, reservations, connections, listeners, external addresses) but previously lacked a mechanism for external components to track and react to these events programmatically. This feedback system provides:
Changes Summary
Files Added
node/relay/src/event_feedback.rsFiles Modified
node/relay/src/lib.rsEventFeedbackManagerinitializationRelayP2pWorkernode/relay/src/p2p.rsKey Features
1. Comprehensive Event Coverage
The system tracks 19 distinct event types:
Circuit Events
CircuitAccepted- Circuit relay request acceptedCircuitClosed- Circuit closed (gracefully or with error)CircuitDenied- Circuit relay request deniedReservation Events
ReservationAccepted- Reservation request acceptedReservationClosed- Reservation closed gracefullyReservationDenied- Reservation request deniedReservationTimedOut- Reservation expiredConnection Events
ConnectionEstablished- New peer connection establishedConnectionClosed- Connection closed (with reason)ConnectionError- Connection attempt failedListener Events
ListenerStarted- New listener started on addressListenerClosed- Listener stoppedListenerExpired- Listener address expiredExternal Address Events
ExternalAddrCandidate- New external address candidate discoveredExternalAddrConfirmed- External address confirmedExternalAddrExpired- External address expiredExternalAddrOfPeer- Discovered external address of peerOther Events
Dialing- Outbound dial initiatedUnknownEvent- Catch-all for unhandled events2. Dual Subscription Model
Broadcast Subscriptions
Subscribe to continuous event streams via
mpsc::UnboundedReceiver:One-Time Subscriptions
Subscribe to specific events via
oneshot::Receiver:3. Active Event Tracking
The
EventFeedbackManagermaintains state for active events:Track metrics and query active events:
API Reference
Public Methods on
RelayP2pWorkerBroadcast Subscriptions
One-Time Subscriptions
Statistics
EventResultEnumAll events are returned as variants of the
EventResultenum:Helper methods:
Usage Examples
Example 1: Monitor All Circuit Activity
Example 2: Track Specific Circuit Lifetime
Example 3: Monitor Connection Health
Example 4: Dashboard/Monitoring Service
Example 5: Testing & Validation
Implementation Details
Event Flow
p2p.rscalls correspondingnotify_*methodEventResultwith timing/metadataThread Safety
EventFeedbackManageris wrapped inArcfor shared ownershipMutexfor thread-safe access.awaitproperly without blockingMemory Management
Testing Recommendations
EventFeedbackManagermethodsBreaking Changes
None. This is a purely additive change that doesn't modify existing APIs.
Performance Impact
mpsc::unboundedchannelsChecklist
RelayP2pWorkerEventResultenum