You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iggy.apache.org by gk...@apache.org on 2025/11/14 19:16:50 UTC

(iggy) branch metadata_module_init updated (e16884225 -> 00ceb9402)

This is an automated email from the ASF dual-hosted git repository.

gkoszyk pushed a change to branch metadata_module_init
in repository https://gitbox.apache.org/repos/asf/iggy.git


 discard e16884225 feat(cluster): define metadata module and add conseus, messages modules
     new 00ceb9402 feat(cluster): define metadata module and add conseus, messages modules

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (e16884225)
            \
             N -- N -- N   refs/heads/metadata_module_init (00ceb9402)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 core/modules/metadata/Cargo.toml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


(iggy) 01/01: feat(cluster): define metadata module and add conseus, messages modules

Posted by gk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gkoszyk pushed a commit to branch metadata_module_init
in repository https://gitbox.apache.org/repos/asf/iggy.git

commit 00ceb940295b20c4d43b1bd090bcdc70e56a4269
Author: numminex <g....@gmail.com>
AuthorDate: Fri Nov 14 20:14:55 2025 +0100

    feat(cluster): define metadata module and add conseus, messages modules
---
 Cargo.lock                                  |  15 +++
 Cargo.toml                                  |   3 +
 core/modules/Cargo.toml                     |  24 +++++
 core/modules/consensus/Cargo.toml           |  31 ++++++
 core/modules/consensus/src/lib.rs           |  16 +++
 core/modules/messages/Cargo.toml            |  31 ++++++
 core/modules/messages/src/consensus.rs      | 161 ++++++++++++++++++++++++++++
 core/modules/messages/src/lib.rs            |  24 +++++
 core/modules/metadata/Cargo.toml            |  32 ++++++
 core/modules/metadata/src/impls/metadata.rs |  42 ++++++++
 core/modules/metadata/src/impls/mod.rs      |  17 +++
 core/modules/metadata/src/lib.rs            |  21 ++++
 core/modules/metadata/src/stm/mod.rs        |   3 +
 core/modules/metadata/src/stm/mux.rs        |  19 ++++
 core/modules/metadata/src/stm/stream.rs     |  16 +++
 15 files changed, 455 insertions(+)

diff --git a/Cargo.lock b/Cargo.lock
index 9b2474380..5c8af9852 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1693,6 +1693,10 @@ dependencies = [
  "crossbeam-utils",
 ]
 
+[[package]]
+name = "consensus"
+version = "0.1.0"
+
 [[package]]
 name = "console"
 version = "0.15.11"
@@ -5213,6 +5217,17 @@ version = "2.7.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
 
+[[package]]
+name = "messages"
+version = "0.1.0"
+
+[[package]]
+name = "metadata"
+version = "0.1.0"
+dependencies = [
+ "messages",
+]
+
 [[package]]
 name = "miette"
 version = "7.6.0"
diff --git a/Cargo.toml b/Cargo.toml
index 7fb7a4d5a..3093815fa 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -36,6 +36,9 @@ members = [
     "core/connectors/sources/postgres_source",
     "core/connectors/sources/random_source",
     "core/integration",
+    "core/modules/consensus",
+    "core/modules/messages",
+    "core/modules/metadata",
     "core/sdk",
     "core/server",
     "core/tools",
diff --git a/core/modules/Cargo.toml b/core/modules/Cargo.toml
new file mode 100644
index 000000000..7cb4f479d
--- /dev/null
+++ b/core/modules/Cargo.toml
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+[workspace]
+members = [
+    "consensus",
+    "messages",
+    "metadata",
+]
+resolver = "2"
diff --git a/core/modules/consensus/Cargo.toml b/core/modules/consensus/Cargo.toml
new file mode 100644
index 000000000..9bf2b9ad8
--- /dev/null
+++ b/core/modules/consensus/Cargo.toml
@@ -0,0 +1,31 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+[package]
+name = "consensus"
+version = "0.1.0"
+description = "Iggy consensus module"
+edition = "2024"
+license = "Apache-2.0"
+keywords = ["iggy", "messaging", "streaming"]
+categories = ["command-line-utilities", "database", "network-programming"]
+homepage = "https://iggy.apache.org"
+documentation = "https://iggy.apache.org/docs"
+repository = "https://github.com/apache/iggy"
+readme = "../../../README.md"
+
+[dependencies]
diff --git a/core/modules/consensus/src/lib.rs b/core/modules/consensus/src/lib.rs
new file mode 100644
index 000000000..b248758bc
--- /dev/null
+++ b/core/modules/consensus/src/lib.rs
@@ -0,0 +1,16 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
diff --git a/core/modules/messages/Cargo.toml b/core/modules/messages/Cargo.toml
new file mode 100644
index 000000000..c9b56fc06
--- /dev/null
+++ b/core/modules/messages/Cargo.toml
@@ -0,0 +1,31 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+[package]
+name = "messages"
+version = "0.1.0"
+description = "Iggy cluster network messages"
+edition = "2024"
+license = "Apache-2.0"
+keywords = ["iggy", "messaging", "streaming"]
+categories = ["command-line-utilities", "database", "network-programming"]
+homepage = "https://iggy.apache.org"
+documentation = "https://iggy.apache.org/docs"
+repository = "https://github.com/apache/iggy"
+readme = "../../../README.md"
+
+[dependencies]
diff --git a/core/modules/messages/src/consensus.rs b/core/modules/messages/src/consensus.rs
new file mode 100644
index 000000000..60f04524e
--- /dev/null
+++ b/core/modules/messages/src/consensus.rs
@@ -0,0 +1,161 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use std::marker::PhantomData;
+
+// TODO: Header generic
+// TODO: We will have to impl something like this (NOT ONE TO ONE JUST A SKETCH) as we will use `bytemuck`:
+/*
+// Generic Message type
+#[repr(C)]
+pub struct Message<H: Header = GenericHeader> {
+    buffer: AlignedBuffer<ALIGNED_TO_HEADER_SIZE>,
+    _phantom: PhantomData<H>,
+}
+
+// Trait that all headers must implement
+pub trait Header: Sized {
+    const COMMAND: Command;
+
+    fn size(&self) -> u32;
+    fn command(&self) -> Command;
+    fn checksum(&self) -> u128;
+}
+
+// Command enum (simplified)
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+#[repr(u8)]
+pub enum Command {
+    Reserved = 0,
+    Ping = 1,
+    Pong = 2,
+    Request = 3,
+    Prepare = 4,
+    PrepareOk = 5,
+    Reply = 6,
+    Commit = 7,
+    // ... etc
+}
+
+// Generic header for base Message
+#[repr(C)]
+pub struct GenericHeader {
+    checksum: u128,
+    command: Command,
+    size: u32,
+    // ... other fields
+}
+
+impl Header for GenericHeader {
+    const COMMAND: Command = Command::Reserved;
+
+    fn size(&self) -> u32 { self.size }
+    fn command(&self) -> Command { self.command }
+    fn checksum(&self) -> u128 { self.checksum }
+}
+
+// Specific header types
+#[repr(C)]
+pub struct PrepareHeader {
+    checksum: u128,
+    command: Command,
+    size: u32,
+    // ... prepare-specific fields
+    view: u32,
+    op: u64,
+    commit: u64,
+}
+
+impl Header for PrepareHeader {
+    const COMMAND: Command = Command::Prepare;
+
+    fn size(&self) -> u32 { self.size }
+    fn command(&self) -> Command { self.command }
+    fn checksum(&self) -> u128 { self.checksum }
+*/
+
+// And then for Message impl
+/*
+impl<H: Header> Message<H> {
+    // Access header (no stored pointer needed!)
+    pub fn header(&self) -> &H {
+        assert!(size_of::<H>() <= ALIGNED_TO_HEADER_SIZE);
+        unsafe { &*(self.buffer.as_ptr() as *const H) }
+    }
+
+    pub fn header_mut(&mut self) -> &mut H {
+        unsafe { &mut *(self.buffer.as_mut_ptr() as *mut H) }
+    }
+
+    pub fn body(&self) -> &[u8] {
+        let header_size = size_of::<H>();
+        let total_size = self.header().size() as usize;
+        &self.buffer[header_size..total_size]
+    }
+
+    pub fn body_mut(&mut self) -> &mut [u8] {
+        let header_size = size_of::<H>();
+        let total_size = self.header().size() as usize;
+        &mut self.buffer.as_mut()[header_size..total_size]
+    }
+
+    pub fn as_bytes(&self) -> &[u8] {
+        &self.buffer[..self.header().size() as usize]
+    }
+
+    pub fn base(&self) -> &Message<GenericHeader> {
+        unsafe { &*(self as *const Self as *const Message<GenericHeader>) }
+    }
+
+    pub fn base_mut(&mut self) -> &mut Message<GenericHeader> {
+        unsafe { &mut *(self as *mut Self as *mut Message<GenericHeader>) }
+    }
+
+    pub fn try_into<T: Header>(self) -> Option<Message<T>> {
+        if self.header().command() == T::COMMAND {
+            Some(unsafe { std::mem::transmute(self) })
+        } else {
+            None
+        }
+    }
+}
+*/
+
+// Then for the `Request` header we will have to store an `Operation` enum
+/*
+ Define your operation enum
+#[repr(u8)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum Operation {
+    // Metadata operations
+    CreateTopic = 1,
+    DeleteTopic = 2,
+    ListTopics = 3,
+    CreatePartition = 4,
+
+    // Partition operations
+    Produce = 100,
+    Consume = 101,
+    Fetch = 102,
+}
+*/
+
+// Which will have an method that returns discriminator between Metadata and Partition requests
+
+pub struct Message<H> {
+    _phantom_header: PhantomData<H>,
+}
diff --git a/core/modules/messages/src/lib.rs b/core/modules/messages/src/lib.rs
new file mode 100644
index 000000000..61aedd2f5
--- /dev/null
+++ b/core/modules/messages/src/lib.rs
@@ -0,0 +1,24 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Iggy cluster network messages
+
+pub mod consensus;
+
+// TODO: I think this module should be part of consesus module
+// There is potential for cyclic reference, as consesus requires messages, but messages require
+// command type from consesus layer.
diff --git a/core/modules/metadata/Cargo.toml b/core/modules/metadata/Cargo.toml
new file mode 100644
index 000000000..e6649ad66
--- /dev/null
+++ b/core/modules/metadata/Cargo.toml
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+[package]
+name = "metadata"
+version = "0.1.0"
+description = "Iggy metadata module"
+edition = "2024"
+license = "Apache-2.0"
+keywords = ["iggy", "messaging", "streaming"]
+categories = ["database", "network-programming"]
+homepage = "https://iggy.apache.org"
+documentation = "https://iggy.apache.org/docs"
+repository = "https://github.com/apache/iggy"
+readme = "../../../README.md"
+
+[dependencies]
+messages = { path = "../messages" }
diff --git a/core/modules/metadata/src/impls/metadata.rs b/core/modules/metadata/src/impls/metadata.rs
new file mode 100644
index 000000000..b1083c903
--- /dev/null
+++ b/core/modules/metadata/src/impls/metadata.rs
@@ -0,0 +1,42 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use messages::consensus::Message;
+
+// TODO: Define a trait (probably in some external crate)
+#[expect(unused)]
+trait Metadata {
+    // TODO: I was thinking about having the `RequestHeader` be generic over type of request
+    // but I think having the `Operation` enum return an discriminant, and handle it outside of `Metadata` is good enough.
+    type Header;
+    fn handle(&self, message: Message<Self::Header>);
+}
+
+#[expect(unused)]
+struct IggyMetadata<C, M, J, S> {
+    consensus: C,
+    mux_stm: M,
+    journal: J,
+    snapshot: S,
+}
+
+impl<C, M, J, S> Metadata for IggyMetadata<C, M, J, S> {
+    type Header = (); // RequestMetadataHeader;
+
+    #[expect(unused)]
+    fn handle(&self, message: Message<Self::Header>) {}
+}
diff --git a/core/modules/metadata/src/impls/mod.rs b/core/modules/metadata/src/impls/mod.rs
new file mode 100644
index 000000000..1fb71a3cf
--- /dev/null
+++ b/core/modules/metadata/src/impls/mod.rs
@@ -0,0 +1,17 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+pub mod metadata;
diff --git a/core/modules/metadata/src/lib.rs b/core/modules/metadata/src/lib.rs
new file mode 100644
index 000000000..c86b13993
--- /dev/null
+++ b/core/modules/metadata/src/lib.rs
@@ -0,0 +1,21 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Iggy metadata module
+
+mod impls;
+pub mod stm;
diff --git a/core/modules/metadata/src/stm/mod.rs b/core/modules/metadata/src/stm/mod.rs
new file mode 100644
index 000000000..5b6609ec8
--- /dev/null
+++ b/core/modules/metadata/src/stm/mod.rs
@@ -0,0 +1,3 @@
+mod mux;
+mod stream;
+// TODO: Add more state machines.
diff --git a/core/modules/metadata/src/stm/mux.rs b/core/modules/metadata/src/stm/mux.rs
new file mode 100644
index 000000000..7907c8db8
--- /dev/null
+++ b/core/modules/metadata/src/stm/mux.rs
@@ -0,0 +1,19 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#[expect(unused)]
+struct MuxStateMachine {}
diff --git a/core/modules/metadata/src/stm/stream.rs b/core/modules/metadata/src/stm/stream.rs
new file mode 100644
index 000000000..b248758bc
--- /dev/null
+++ b/core/modules/metadata/src/stm/stream.rs
@@ -0,0 +1,16 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.