Skip to content

Comments

Add RandomRPC node selection mode#84

Merged
poopoothegorilla merged 4 commits intomainfrom
round-robin
Feb 20, 2026
Merged

Add RandomRPC node selection mode#84
poopoothegorilla merged 4 commits intomainfrom
round-robin

Conversation

@poopoothegorilla
Copy link
Collaborator

Summary

  • Adds a new RandomRPC node selection mode that picks a random healthy RPC on every SelectRPC call, bypassing the sticky activeNode cache
  • Preserves application-layer subscriptions during RPC rotation by not calling UnsubscribeAllExceptAliveLoop when switching nodes
  • Disables lease-based rotation for this mode (same as existing RoundRobin)

Motivation

All existing selection modes are sticky — selectNode() returns the cached active node as long as it's alive. This new mode distributes RPC calls across healthy nodes without tearing down subscriptions on rotation.

Ref: PLEX-2537

Changes

  • node_selector.go: New NodeSelectionModeRandomRPC constant + factory registration
  • node_selector_random_rpc.go: Selector using math/rand/v2 to pick a random alive node
  • multi_node.go: selectRandomRPCNode() path that skips activeNode caching and subscription teardown; lease check disabled for RandomRPC
  • Tests for selector behavior and MultiNode integration (non-sticky, no-unsub, lease-disable, error cases)

@github-actions
Copy link

👋 poopoothegorilla, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

Copy link
Contributor

@dhaidashenko dhaidashenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. Once merged, we should soak it on staging

@poopoothegorilla poopoothegorilla enabled auto-merge (squash) February 20, 2026 14:00
@poopoothegorilla poopoothegorilla merged commit e82bc07 into main Feb 20, 2026
22 checks passed
@poopoothegorilla poopoothegorilla deleted the round-robin branch February 20, 2026 15:10
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.

3 participants