From 9448e23dc9bfe74decf0a1bbfa6525777f10a264 Mon Sep 17 00:00:00 2001
From: Tyler Neely <t@jujit.su>
Date: Thu, 27 Oct 2022 13:36:53 +0000
Subject: [PATCH] Check-in basic shard scheduler skeleton

---
 src/storage/v3/shard_manager.hpp   |  4 ++-
 src/storage/v3/shard_scheduler.hpp | 43 ++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 src/storage/v3/shard_scheduler.hpp

diff --git a/src/storage/v3/shard_manager.hpp b/src/storage/v3/shard_manager.hpp
index a119148e9..ba59c403f 100644
--- a/src/storage/v3/shard_manager.hpp
+++ b/src/storage/v3/shard_manager.hpp
@@ -28,6 +28,7 @@
 #include <storage/v3/shard_rsm.hpp>
 #include "coordinator/shard_map.hpp"
 #include "storage/v3/config.hpp"
+#include "storage/v3/shard_scheduler.hpp"
 
 namespace memgraph::storage::v3 {
 
@@ -78,7 +79,7 @@ template <typename IoImpl>
 class ShardManager {
  public:
   ShardManager(io::Io<IoImpl> io, Address coordinator_leader, coordinator::ShardMap shard_map)
-      : io_(io), coordinator_leader_(coordinator_leader), shard_map_{std::move(shard_map)} {}
+      : io_(io), coordinator_leader_(coordinator_leader), shard_map_{std::move(shard_map)}, shard_scheduler_(io) {}
 
   /// Periodic protocol maintenance. Returns the time that Cron should be called again
   /// in the future.
@@ -133,6 +134,7 @@ class ShardManager {
 
  private:
   io::Io<IoImpl> io_;
+  ShardScheduler<IoImpl> shard_scheduler_;
   std::map<uuid, ShardRaft<IoImpl>> rsm_map_;
   std::priority_queue<std::pair<Time, uuid>, std::vector<std::pair<Time, uuid>>, std::greater<>> cron_schedule_;
   Time next_cron_ = Time::min();
diff --git a/src/storage/v3/shard_scheduler.hpp b/src/storage/v3/shard_scheduler.hpp
new file mode 100644
index 000000000..6cb1bf421
--- /dev/null
+++ b/src/storage/v3/shard_scheduler.hpp
@@ -0,0 +1,43 @@
+// Copyright 2022 Memgraph Ltd.
+//
+// Use of this software is governed by the Business Source License
+// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
+// License, and you may not use this file except in compliance with the Business Source License.
+//
+// As of the Change Date specified in that file, in accordance with
+// the Business Source License, use of this software will be governed
+// by the Apache License, Version 2.0, included in the file
+// licenses/APL.txt.
+
+#pragma once
+
+#include <boost/asio/thread_pool.hpp>
+#include <boost/uuid/uuid.hpp>
+
+#include "io/rsm/raft.hpp"
+#include "query/v2/requests.hpp"
+#include "storage/v3/shard_manager.hpp"
+
+namespace memgraph::storage::v3 {
+
+using memgraph::io::rsm::Raft;
+using memgraph::io::rsm::WriteRequest;
+using memgraph::io::rsm::WriteResponse;
+using memgraph::msgs::ReadRequests;
+using memgraph::msgs::ReadResponses;
+using memgraph::msgs::WriteRequests;
+using memgraph::msgs::WriteResponses;
+
+template <typename IoImpl>
+using ShardRaft = Raft<IoImpl, ShardRsm, WriteRequests, WriteResponses, ReadRequests, ReadResponses>;
+
+template <class IoImpl>
+class ShardScheduler {
+  std::map<boost::uuids::uuid, ShardRaft<IoImpl>> rsm_map_;
+  io::Io<IoImpl> io_;
+
+ public:
+  ShardScheduler(io::Io<IoImpl> io) : io_(io) {}
+};
+
+}  // namespace memgraph::storage::v3