You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: refine docs for feature-flag adapt-network-v1
Complete the pseudo code to produce the conflict.
Add doc in the feature-flags section in `docs` crate.
Add link to this feature-flags for `RaftNetworkV2` doc.
Copy file name to clipboardExpand all lines: openraft/src/docs/getting_started/getting-started.md
+26-14Lines changed: 26 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -80,7 +80,7 @@ pub struct TypeConfig {}
80
80
impl openraft::RaftTypeConfig for TypeConfig {
81
81
type D = Request;
82
82
type R = Response;
83
-
83
+
84
84
// Following are absent in `declare_raft_types` and filled with default values:
85
85
type NodeId = u64;
86
86
type Node = openraft::impls::BasicNode;
@@ -91,7 +91,7 @@ impl openraft::RaftTypeConfig for TypeConfig {
91
91
}
92
92
```
93
93
94
-
> In the above `TypeConfig` declaration,
94
+
> In the above `TypeConfig` declaration,
95
95
> -`NodeId` is the identifier of a node in the cluster, which implements [`NodeId`] trait.
96
96
> -`Node` is the node type that contains the node's address, etc., which implements [`Node`] trait.
97
97
> -`Entry` is the log entry type that will be stored in the raft log,
@@ -233,17 +233,29 @@ When the server receives a Raft RPC, it simply passes it to its `raft` instance
233
233
For a real-world implementation, you may want to use [Tonic gRPC](https://github.com/hyperium/tonic) to handle gRPC-based communication between Raft nodes. The [databend-meta](https://github.com/databendlabs/databend/blob/6603392a958ba8593b1f4b01410bebedd484c6a9/metasrv/src/network.rs#L89) project provides an excellent real-world example of a Tonic gRPC-based Raft network implementation.
234
234
235
235
236
-
Note: when implementing `RaftNetworkV2<T>` where `T` is a supertype of `RaftTypeConfig` (for instance, `impl<T: MySuperType> RaftNetworkV2<T> for YourNetworkType<T>`), the compiler may complain with the following error:
237
-
238
-
```text
239
-
conflicting implementations of trait `RaftNetworkV2<_>` for type `YourNetworkType<_>`
240
-
conflicting implementation in crate `openraft`:
241
-
- impl<C, V1> RaftNetworkV2<C> for V1
242
-
where C: RaftTypeConfig, V1: RaftNetwork<C>, <C as RaftTypeConfig>::SnapshotData: tokio::io::async_read::AsyncRead, <C as RaftTypeConfig>::SnapshotData: tokio::io::async_write::AsyncWrite, <C as RaftTypeConfig>::SnapshotData: tokio::io::async_seek::AsyncSeek, <C as RaftTypeConfig>::SnapshotData: Unpin;
243
-
downstream crates may implement trait `openraft::RaftNetwork<_>` for type `YourNetworkType<_>`
244
-
```
245
-
246
-
If so, you will want to disable the feature `adapt-network-v1`, which will remove forward compatibility for V1 implementations, but will also fix this error.
236
+
> ### Trouble shooting: implementation conflicts
237
+
>
238
+
> When implementing `RaftNetworkV2<T>` for a generic type parameter `T`, you might
239
+
> encounter a compiler error about conflicting implementations. This happens
240
+
> because Openraft provides a blanket implementation that adapts `RaftNetwork`
241
+
> implementations to `RaftNetworkV2`. For example:
0 commit comments