Skip to content

Conversation

@ariesdevil
Copy link
Contributor

@ariesdevil ariesdevil commented Nov 28, 2025

Add Multi-Raft Support via openraft-multi Crate

Summary

This PR introduces Multi-Raft support for OpenRaft through a new standalone crate openraft-multi.

It provides network adapters for efficient connection sharing across multiple Raft groups within a single process.

This is a separate crate that does not affect the core openraft crate.

Key Features

  • Connection Sharing - Multiple Raft groups share the same network connections, reducing resource overhead
  • Simple Adapter Pattern - Just implement GroupedRpc on your router, get RaftNetworkV2 for free
  • Type Safety - Full generic support for custom GroupId types
  • Runtime Agnostic - Works with any async runtime (tokio, compio, monoio, etc.)

New Components

Component Description
GroupedRpc trait Defines RPC methods with (target, group_id) routing
GroupNetworkAdapter Wraps GroupedRpc impl, auto-implements RaftNetworkV2
GroupNetworkFactory Simple wrapper holding (factory, group_id)

Fix: #1485

Checklist

  • Updated guide with pertinent info (may not always apply).
  • Squash down commits to one or two logical commits which clearly describe the work you've done.
  • Unittest is a friend:)

This change is Reviewable

@drmingdrmer
Copy link
Member

There are some design issue with this PR, for example, should a MultiRaftNetwork implementation manage connections to more than one nodes? It looks it is a wrapper of a single RaftNetwork, then it should not have multiple connections. But if it does not have multiple connections, how does it route request belonging to different group to corresponding nodes?

IMHO, network sharing is a just a application level task to do, it does not require the lib(openraft) to add any feature to support it.

@ariesdevil
Copy link
Contributor Author

PTAL again

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.

Support Multi-Raft

2 participants