prepare/prepareok
diff --git a/server/src/versioning.rs b/server/src/versioning.rs index edb07f5..8394fe0 100644 --- a/server/src/versioning.rs +++ b/server/src/versioning.rs
@@ -4,7 +4,7 @@ const VERSION: &str = env!("CARGO_PKG_VERSION"); -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub struct SemanticVersion { pub major: u32, pub minor: u32,
diff --git a/server/src/vsr/header.rs b/server/src/vsr/header.rs index 613c29b..e56fa8b 100644 --- a/server/src/vsr/header.rs +++ b/server/src/vsr/header.rs
@@ -1,12 +1,67 @@ +use crate::versioning::SemanticVersion; +use super::{Operation, ProtocolVersion}; + pub enum Header { + // TODO: Add Request header, for now let's just use the `Command` enum + // and ignore the request_number and all of the client side data required by VSR. Prepare(Prepare), PrepareOk(PrepareOk), } +#[derive(Debug, Clone)] pub struct Prepare { - + pub checksum: u128, + pub checksum_body: u128, + // Reserved for further usage, for encryption. + pub nonce_reserved: u128, + pub cluster: u128, + pub size: u32, + // Reserved for further usage. + pub epoch: u32, + pub view_number: u32, + pub release: SemanticVersion, + // Version of VSR protocol. + pub protocol_version: ProtocolVersion, + // Currently not used, since our body has that information in it's payload. + pub command: u32, + pub replica: u8, + // Reserved for further usage. + pub parent: u128, + pub request_checksum: u128, + pub checkpoint_id: u128, + pub session_id: u64, + pub op_number: u64, + pub commit_number: u64, + pub timestamp: u64, + pub request_number: u32, + pub operation: Operation, } +#[derive(Debug, Clone)] pub struct PrepareOk { - + pub checksum: u128, + pub checksum_body: u128, + // Reserved for further usage, for encryption. + pub nonce_reserved: u128, + pub cluster: u128, + pub size: u32, + // Reserved for further usage. + pub epoch: u32, + pub view: u32, + pub release: SemanticVersion, + // Version of VSR Protocol + pub protocol_version: ProtocolVersion, + // Currently not used, since our body has that information in it's payload. + pub command: u32, + pub replica: u8, + // Reserved for further usage. + pub parent: u128, + pub prepare_checksum: u128, + pub checkpoint_id: u128, + pub session_id: u64, + pub op_number: u64, + pub commit_number: u64, + pub timestamp: u64, + pub request_number: u32, + pub operation: Operation, }
diff --git a/server/src/vsr/message.rs b/server/src/vsr/message.rs index e5317ff..c198573 100644 --- a/server/src/vsr/message.rs +++ b/server/src/vsr/message.rs
@@ -1,6 +1,7 @@ +use bytes::Bytes; use super::header::Header; pub struct IggyMessage { header: Header, - body: () + body: Bytes, }
diff --git a/server/src/vsr/mod.rs b/server/src/vsr/mod.rs index 450c170..97d9fb0 100644 --- a/server/src/vsr/mod.rs +++ b/server/src/vsr/mod.rs
@@ -9,6 +9,18 @@ pub(crate) type CommitNumber = u64; pub(crate) type ViewNumber = u32; pub(crate) type Version = usize; +pub(crate) type ProtocolVersion = u16; + + +#[derive(Debug, Clone)] +pub(crate) enum Operation { + /// Authorization + Auth, + /// Metadata such as CRUD on streams / topics / partitions + Metadata, + /// Messages(User data) persisted by our storage. + Messages, +} // TODO: const generics ? pub(crate) struct QuorumCounter<T> {
diff --git a/server/src/vsr/replica.rs b/server/src/vsr/replica.rs index c820d08..3e38955 100644 --- a/server/src/vsr/replica.rs +++ b/server/src/vsr/replica.rs
@@ -1,5 +1,5 @@ use super::*; -use crate::versioning::SemanticVersion; +use crate::{command::ServerCommand, versioning::SemanticVersion}; use client_table::ClientTable; use status::Status; use std::marker::PhantomData; @@ -45,8 +45,66 @@ } impl<S,B> Replica<S,B> { + fn on_command(&self, command: ServerCommand) { + match command { + ServerCommand::CreateStream(command) => { - fn on_command(&self) { + }, + ServerCommand::UpdateStream(command) => { + } + ServerCommand::DeleteStream(command) => { + + } + ServerCommand::PurgeStream(command) => { + + } + ServerCommand::CreateTopic(command) => { + + } + ServerCommand::UpdateTopic(command) => { + + } + ServerCommand::DeleteTopic(command) => { + + } + ServerCommand::PurgeTopic(command) => { + + } + ServerCommand::CreatePartitions(command) => { + + } + ServerCommand::DeletePartitions(command) => { + + } + ServerCommand::CreateConsumerGroup(command) => { + + } + ServerCommand::DeleteConsumerGroup(command) => { + + } + ServerCommand::CreateUser(command) => { + + } + ServerCommand::UpdateUser(command) => { + + } + ServerCommand::DeleteUser(command) => { + + } + ServerCommand::ChangePassword(command) => { + + } + ServerCommand::UpdatePermissions(command) => { + + } + ServerCommand::CreatePersonalAccessToken(command) => { + + } + ServerCommand::DeletePersonalAccessToken(command) => { + + } + _ => { unreachable!();} + } } }