implements serialize and deserialize for RaftMetrics.

This commit is contained in:
Sunli 2020-11-04 11:22:25 +08:00
parent ea6f1c2020
commit 302d3e54fe
4 changed files with 10 additions and 3 deletions

View File

@ -4,6 +4,10 @@ This changelog follows the patterns described here: https://keepachangelog.com/e
## [unreleased]
## 0.5.5
### changed
- Added `#[derive(Serialize, Deserialize)]` to `RaftMetrics`, `State`.
## 0.5.4
### fixed
- Fixed [#82](https://github.com/async-raft/async-raft/issues/82) where client reads were not behaving correctly for single node clusters. Single node integration tests have been updated to ensure this functionality is working as needed.

View File

@ -1,6 +1,6 @@
[package]
name = "async-raft"
version = "0.5.4"
version = "0.5.5"
edition = "2018"
authors = ["Anthony Dodd <Dodd.AnthonyJosiah@gmail.com>"]
categories = ["algorithms", "asynchronous", "data-structures"]

View File

@ -12,6 +12,7 @@ use std::sync::Arc;
use futures::future::{AbortHandle, Abortable};
use futures::stream::FuturesOrdered;
use serde::{Deserialize, Serialize};
use tokio::stream::StreamExt;
use tokio::sync::{broadcast, mpsc, oneshot, watch};
use tokio::task::JoinHandle;
@ -434,7 +435,7 @@ pub(self) enum SnapshotUpdate {
///////////////////////////////////////////////////////////////////////////////////////////////////
/// All possible states of a Raft node.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum State {
/// The node is completely passive; replicating entries, but neither voting nor timing out.
NonVoter,

View File

@ -7,12 +7,14 @@
//! Metrics are observed on a running Raft node via the `Raft::metrics()` method, which will
//! return a stream of metrics.
use serde::{Deserialize, Serialize};
use crate::core::State;
use crate::raft::MembershipConfig;
use crate::NodeId;
/// A set of metrics describing the current state of a Raft node.
#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct RaftMetrics {
/// The ID of the Raft node.
pub id: NodeId,