Skip to content

Commit

Permalink
raft: add serde support for vote_reply
Browse files Browse the repository at this point in the history
Signed-off-by: Noah Watkins <noah@redpanda.com>
  • Loading branch information
dotnwat committed Jul 6, 2022
1 parent e975c1c commit d3d407a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/v/cluster/tests/serialization_rt_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2078,6 +2078,16 @@ SEASTAR_THREAD_TEST_CASE(serde_reflection_roundtrip) {
};
roundtrip_test(data);
}
{
raft::vote_reply data{
.target_node_id = raft::
vnode{tests::random_named_int<model::node_id>(), tests::random_named_int<model::revision_id>()},
.term = tests::random_named_int<model::term_id>(),
.granted = tests::random_bool(),
.log_ok = tests::random_bool(),
};
roundtrip_test(data);
}
}

SEASTAR_THREAD_TEST_CASE(cluster_property_kv_exchangable_with_pair) {
Expand Down
8 changes: 7 additions & 1 deletion src/v/raft/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ struct vote_request : serde::envelope<vote_request, serde::version<0>> {
}
};

struct vote_reply {
struct vote_reply : serde::envelope<vote_reply, serde::version<0>> {
// node id to validate on receiver
vnode target_node_id;
/// \brief callee's term, for the caller to upate itself
Expand All @@ -325,6 +325,12 @@ struct vote_reply {
bool log_ok = false;

friend std::ostream& operator<<(std::ostream& o, const vote_reply& r);

friend bool operator==(const vote_reply&, const vote_reply&) = default;

auto serde_fields() {
return std::tie(target_node_id, term, granted, log_ok);
}
};

/// This structure is used by consensus to notify other systems about group
Expand Down

0 comments on commit d3d407a

Please sign in to comment.