Skip to content

Conversation

@bittcrafter
Copy link
Collaborator

Refactored the shared module across cluster implementations to support two distinct forwarding modes:

  1. Targeted Client Forwarding (forward_to_target_client):

    • New method added to directly forward messages to a specific client ID
    • Handles both local and cross-node forwarding scenarios
    • Uses gRPC for inter-node communication with timeout handling
    • Maintains statistics for forwarding operations
  2. Subscription-Based Forwarding (forward_to_subscriptions):

    • Existing broadcast logic now encapsulated in this method
    • Maintains previous behavior for non-targeted messages

Key Changes:

  • Added get_target_node_id() method to router for client-node mapping
  • Modified main forwards() method to dispatch based on publish.target_clientid presence
  • Implemented consistent logic across all cluster implementations (broadcast and raft)
  • Added proper logging and error handling for cross-node communications
  • Maintained backward compatibility with existing subscription-based forwarding

Files Modified:

  • rmqtt-plugins/rmqtt-cluster-broadcast/src/shared.rs
  • rmqtt-plugins/rmqtt-cluster-raft/src/router.rs
  • rmqtt-plugins/rmqtt-cluster-raft/src/shared.rs
  • rmqtt/src/shared.rs

This refactor enables more efficient direct messaging while maintaining existing pub/sub functionality.

Refactored the shared module across cluster implementations to support two distinct forwarding modes:

1. **Targeted Client Forwarding** (`forward_to_target_client`):
   - New method added to directly forward messages to a specific client ID
   - Handles both local and cross-node forwarding scenarios
   - Uses gRPC for inter-node communication with timeout handling
   - Maintains statistics for forwarding operations

2. **Subscription-Based Forwarding** (`forward_to_subscriptions`):
   - Existing broadcast logic now encapsulated in this method
   - Maintains previous behavior for non-targeted messages

**Key Changes:**
* Added `get_target_node_id()` method to router for client-node mapping
* Modified main `forwards()` method to dispatch based on `publish.target_clientid` presence
* Implemented consistent logic across all cluster implementations (broadcast and raft)
* Added proper logging and error handling for cross-node communications
* Maintained backward compatibility with existing subscription-based forwarding

**Files Modified:**
* rmqtt-plugins/rmqtt-cluster-broadcast/src/shared.rs
* rmqtt-plugins/rmqtt-cluster-raft/src/router.rs
* rmqtt-plugins/rmqtt-cluster-raft/src/shared.rs
* rmqtt/src/shared.rs

This refactor enables more efficient direct messaging while maintaining existing pub/sub functionality.
@bittcrafter bittcrafter merged commit e0f489b into rmqtt:master Sep 13, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant