krishvishal commented on code in PR #2389:
URL: https://github.com/apache/iggy/pull/2389#discussion_r2551311111
##########
core/common/src/types/consensus/header.rs:
##########
@@ -15,7 +15,310 @@
// specific language governing permissions and limitations
// under the License.
+use bytemuck::{Pod, Zeroable};
+
#[expect(unused)]
pub struct Header {}
-pub trait ConsensusHeader {}
+pub trait ConsensusHeader: Sized + Pod + Zeroable {
+ const COMMAND: Command;
+
+ fn size(&self) -> u32;
+ fn command(&self) -> Command;
+ fn checksum(&self) -> u128;
+ fn cluster(&self) -> u128;
+
+ fn validate(&self) -> Result<(), &'static str>;
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+#[repr(u8)]
+pub enum Command {
+ Reserved = 0,
+
+ Ping = 1,
+ Pong = 2,
+ PingClient = 3,
+ PongClient = 4,
+
+ Request = 5,
+ Prepare = 6,
+ PrepareOk = 7,
+ Reply = 8,
+ Commit = 9,
+
+ StartViewChange = 10,
+ DoViewChange = 11,
+ StartView = 24,
+
+ RequestStartView = 12,
+ RequstHeads = 13,
+ RequestPrepare = 14,
+ RequestReply = 15,
+
+ Headers = 16,
+
+ Eviction = 17,
+
+ RequestBlocks = 18,
+ Block = 19,
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+#[repr(u8)]
+pub enum Operation {
+ Reserved = 0,
+ Root = 1,
+ Register = 2,
+ Reconfigure = 3,
+ Pulse = 4,
+ Upgrade = 5,
Review Comment:
Done
##########
core/common/src/types/consensus/header.rs:
##########
@@ -15,7 +15,310 @@
// specific language governing permissions and limitations
// under the License.
+use bytemuck::{Pod, Zeroable};
+
#[expect(unused)]
pub struct Header {}
-pub trait ConsensusHeader {}
+pub trait ConsensusHeader: Sized + Pod + Zeroable {
+ const COMMAND: Command;
+
+ fn size(&self) -> u32;
+ fn command(&self) -> Command;
+ fn checksum(&self) -> u128;
+ fn cluster(&self) -> u128;
+
+ fn validate(&self) -> Result<(), &'static str>;
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+#[repr(u8)]
+pub enum Command {
+ Reserved = 0,
+
+ Ping = 1,
+ Pong = 2,
+ PingClient = 3,
+ PongClient = 4,
+
+ Request = 5,
+ Prepare = 6,
+ PrepareOk = 7,
+ Reply = 8,
+ Commit = 9,
+
+ StartViewChange = 10,
+ DoViewChange = 11,
+ StartView = 24,
+
+ RequestStartView = 12,
Review Comment:
Done.
##########
core/common/src/types/consensus/header.rs:
##########
@@ -15,7 +15,310 @@
// specific language governing permissions and limitations
// under the License.
+use bytemuck::{Pod, Zeroable};
+
#[expect(unused)]
pub struct Header {}
-pub trait ConsensusHeader {}
+pub trait ConsensusHeader: Sized + Pod + Zeroable {
+ const COMMAND: Command;
+
+ fn size(&self) -> u32;
+ fn command(&self) -> Command;
+ fn checksum(&self) -> u128;
+ fn cluster(&self) -> u128;
+
+ fn validate(&self) -> Result<(), &'static str>;
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+#[repr(u8)]
+pub enum Command {
+ Reserved = 0,
+
+ Ping = 1,
+ Pong = 2,
+ PingClient = 3,
+ PongClient = 4,
+
+ Request = 5,
+ Prepare = 6,
+ PrepareOk = 7,
+ Reply = 8,
+ Commit = 9,
+
+ StartViewChange = 10,
+ DoViewChange = 11,
+ StartView = 24,
+
+ RequestStartView = 12,
+ RequstHeads = 13,
+ RequestPrepare = 14,
+ RequestReply = 15,
+
+ Headers = 16,
+
+ Eviction = 17,
+
+ RequestBlocks = 18,
+ Block = 19,
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+#[repr(u8)]
+pub enum Operation {
+ Reserved = 0,
+ Root = 1,
+ Register = 2,
+ Reconfigure = 3,
+ Pulse = 4,
+ Upgrade = 5,
+
+ CreateStream = 128,
+ UpdateStream = 129,
+ DeleteStream = 130,
+ PurgeStream = 131,
+ CreateTopic = 132,
+ UpdateTopic = 133,
+ DeleteTopic = 134,
+ PurgeTopic = 135,
+ CreatePartitions = 136,
+ DeletePartitions = 137,
+ DeleteSegments = 138,
+ CreateConsumerGroup = 139,
+ DeleteConsumerGroup = 140,
+ CreateUser = 141,
+ UpdateUser = 142,
+ DeleteUser = 143,
+ ChangePassword = 144,
+ UpdatePermissions = 145,
+ CreatePersonalAccessToken = 146,
+ DeletePersonalAccessToken = 147,
+}
+
+#[repr(C)]
+#[derive(Debug, Clone, Copy)]
+pub struct GenericHeader {
+ pub checksum: u128,
+ pub checksum_padding: u128,
Review Comment:
Done
##########
core/common/src/types/consensus/header.rs:
##########
@@ -15,7 +15,310 @@
// specific language governing permissions and limitations
// under the License.
+use bytemuck::{Pod, Zeroable};
+
#[expect(unused)]
pub struct Header {}
-pub trait ConsensusHeader {}
+pub trait ConsensusHeader: Sized + Pod + Zeroable {
+ const COMMAND: Command;
+
+ fn size(&self) -> u32;
+ fn command(&self) -> Command;
+ fn checksum(&self) -> u128;
+ fn cluster(&self) -> u128;
+
+ fn validate(&self) -> Result<(), &'static str>;
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+#[repr(u8)]
+pub enum Command {
+ Reserved = 0,
+
+ Ping = 1,
+ Pong = 2,
+ PingClient = 3,
+ PongClient = 4,
+
+ Request = 5,
+ Prepare = 6,
+ PrepareOk = 7,
+ Reply = 8,
+ Commit = 9,
+
+ StartViewChange = 10,
+ DoViewChange = 11,
+ StartView = 24,
+
+ RequestStartView = 12,
+ RequstHeads = 13,
+ RequestPrepare = 14,
+ RequestReply = 15,
+
+ Headers = 16,
+
+ Eviction = 17,
+
+ RequestBlocks = 18,
+ Block = 19,
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+#[repr(u8)]
+pub enum Operation {
+ Reserved = 0,
+ Root = 1,
+ Register = 2,
+ Reconfigure = 3,
+ Pulse = 4,
+ Upgrade = 5,
+
+ CreateStream = 128,
+ UpdateStream = 129,
+ DeleteStream = 130,
+ PurgeStream = 131,
+ CreateTopic = 132,
+ UpdateTopic = 133,
+ DeleteTopic = 134,
+ PurgeTopic = 135,
+ CreatePartitions = 136,
+ DeletePartitions = 137,
+ DeleteSegments = 138,
+ CreateConsumerGroup = 139,
+ DeleteConsumerGroup = 140,
+ CreateUser = 141,
+ UpdateUser = 142,
+ DeleteUser = 143,
+ ChangePassword = 144,
+ UpdatePermissions = 145,
+ CreatePersonalAccessToken = 146,
+ DeletePersonalAccessToken = 147,
+}
+
+#[repr(C)]
+#[derive(Debug, Clone, Copy)]
+pub struct GenericHeader {
+ pub checksum: u128,
+ pub checksum_padding: u128,
+ pub checksum_body: u128,
+ pub checksum_body_padding: u128,
+ pub nonce_reserved: u128,
Review Comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]