如何使用 raft-rs crate 和 cargo 构建?
How to use the raft-rs crate and build with cargo?
我尝试构建 single_mem_node example,但作为一个独立的示例并使用 raft-rs
板条箱作为库。
但不幸的是,我在使用 cargo build
进行构建时遇到此构建错误
error[E0599]: no method named `is_empty` found for reference `&raft_proto::protos::eraftpb::Snapshot` in the current scope
--> src/main.rs:123:26
|
123 | if !ready.snapshot().is_empty() {
| ^^^^^^^^ method not found in `&raft_proto::protos::eraftpb::Snapshot`
我已经在 Cargo.toml
中声明了这些依赖项
[dependencies]
protobuf = { version = "2", features = ["with-bytes"] }
raft = "0.6.0-alpha"
slog = "2.5.2"
slog-term = "2.6.0"
slog-async = "2.5.0"
关于如何使用 raft-rs
箱子的说明是:
You can use raft with either rust-protobuf or Prost to encode/decode gRPC messages. We use rust-protobuf by default. To use Prost, build (or depend on) Raft using the prost-codec feature and without default features.
看来我确实错过了 protobuf
周围的某些东西...但是什么?我如何找到它?
貌似添加的方法in this commit, after version 0.6.0-alpha
was released. GitHub shows the master
branch by default, so in the future, try browsing at the commit that corresponds to the version you are using. In this case it is not tagged properly but I think this commit is the published 0.6.0-alpha
version. In the example at that commit, the corresponding line是:
if !raft::is_empty_snap(ready.snapshot()) {
或者,由于 0.6.0-alpha
似乎是在 2019 年 7 月发布的,如果您想要 master
的最新更改,您可以将 Cargo.toml
中的依赖项更改为:
raft = { git = "https://github.com/tikv/raft-rs" }
在这种情况下,cargo 将获取最新的提交并将其哈希存储在 Cargo.lock
中,您可以使用 cargo update
.
更新到较新的提交
我尝试构建 single_mem_node example,但作为一个独立的示例并使用 raft-rs
板条箱作为库。
但不幸的是,我在使用 cargo build
error[E0599]: no method named `is_empty` found for reference `&raft_proto::protos::eraftpb::Snapshot` in the current scope
--> src/main.rs:123:26
|
123 | if !ready.snapshot().is_empty() {
| ^^^^^^^^ method not found in `&raft_proto::protos::eraftpb::Snapshot`
我已经在 Cargo.toml
[dependencies]
protobuf = { version = "2", features = ["with-bytes"] }
raft = "0.6.0-alpha"
slog = "2.5.2"
slog-term = "2.6.0"
slog-async = "2.5.0"
关于如何使用 raft-rs
箱子的说明是:
You can use raft with either rust-protobuf or Prost to encode/decode gRPC messages. We use rust-protobuf by default. To use Prost, build (or depend on) Raft using the prost-codec feature and without default features.
看来我确实错过了 protobuf
周围的某些东西...但是什么?我如何找到它?
貌似添加的方法in this commit, after version 0.6.0-alpha
was released. GitHub shows the master
branch by default, so in the future, try browsing at the commit that corresponds to the version you are using. In this case it is not tagged properly but I think this commit is the published 0.6.0-alpha
version. In the example at that commit, the corresponding line是:
if !raft::is_empty_snap(ready.snapshot()) {
或者,由于 0.6.0-alpha
似乎是在 2019 年 7 月发布的,如果您想要 master
的最新更改,您可以将 Cargo.toml
中的依赖项更改为:
raft = { git = "https://github.com/tikv/raft-rs" }
在这种情况下,cargo 将获取最新的提交并将其哈希存储在 Cargo.lock
中,您可以使用 cargo update
.