diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-08-13 23:36:59 +0200 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-08-13 23:36:59 +0200 |
commit | fad5d37382552af7328dd67d038c1eaf44cf0aee (patch) | |
tree | 140a9282f45e8b730e69080c6ab64d33f86a77a6 | |
parent | 2a6898c9d95c955df724de1221241888ca1d847e (diff) |
Wip for FS remotes
-rw-r--r-- | modules/remote-filesystem/c++/remote.hpp | 49 | ||||
-rw-r--r-- | modules/remote-filesystem/c++/transport.hpp | 53 | ||||
-rw-r--r-- | modules/remote/c++/transfer_loopback.hpp | 2 |
3 files changed, 76 insertions, 28 deletions
diff --git a/modules/remote-filesystem/c++/remote.hpp b/modules/remote-filesystem/c++/remote.hpp index 42cdd03..062d7ee 100644 --- a/modules/remote-filesystem/c++/remote.hpp +++ b/modules/remote-filesystem/c++/remote.hpp @@ -6,54 +6,49 @@ namespace saw { namespace rmt { -struct FileSystem {}; +struct File {}; } template<> -class remote_address<rmt::FileSystem> { +class remote_address<rmt::File> { private: std::filesystem::path path_; public: remote_address(const std::filesystem::path& path__): path_{path__} {} -}; -template<typename Iface, typename Encoding, typename Storage> -class rpc_client<Iface, Encoding, Storage, rmt::FileSystem> { -private: - ptr<remote_address<rmt::FileSystem>> addr_; -public: - rpc_client(ptr<remote_address<rmt::FileSystem>> addr__): - addr_{addr__} - {} -}; + std::string get_path_string() const { + return path_.string(); + } -template<typename Iface, typename Encoding, typename Storage> -class rpc_server<Iface, Encoding, Storage, rmt::FileSystem> { -private: - ptr<remote_address<rmt::FileSystem>> addr_; -public: - rpc_server(ptr<remote_address<rmt::FileSystem>> addr__): - addr_{addr__} - {} + const std::filesystem::path& get_path() const { + return path_; + } }; template<> -class remote<rmt::FileSystem> { +class remote<rmt::File> { private: SAW_FORBID_COPY(remote); SAW_FORBID_MOVE(remote); - + std::map<std::string, ptr<i_data_server<rmt::File>>> registered_data_servers_; public: - error_or<own<remote_address<rmt::FileSystem>>> parse_address(const std::string_view& path_v){ - return heap<remote_address<rmt::FileSystem>>(path_v); + error_or<own<remote_address<rmt::File>>> parse_address(const std::string_view& path_v){ + return heap<remote_address<rmt::File>>(path_v); } - template<typename Iface, typename Encoding, typename Storage> - rpc_server<Iface, Encoding, Storage, rmt::FileSystem> listen(const remote_address<rmt::FileSystem>& addr, typename rpc_server<Iface,Encoding,Storage,rmt::FileSystem>::InterfaceT iface){ - return {addr, std::move(iface)}; + template<typename Schema, typename Encode> + error_or<own<data_server<Schema, Encode, rmt::File>>> data_listen(ref<remote_address<rmt::File>> addr){ + auto insert_res = registered_data_servers_.emplace(std::make_pair(addr.get_path_string(),{})); + if(!insert_res.second){ + return make_error<err::already_exists>(); + } + + auto dat_srv = heap<data_server<Schema, Encode, rmt::File>>(*this, addr); + insert_res.first->second = {dat_srv}; + return dat_srv; } }; } diff --git a/modules/remote-filesystem/c++/transport.hpp b/modules/remote-filesystem/c++/transport.hpp new file mode 100644 index 0000000..367f533 --- /dev/null +++ b/modules/remote-filesystem/c++/transport.hpp @@ -0,0 +1,53 @@ +#pragma once + +#include "remote.hpp" + +#include <forstio/remote/transport.hpp> + +namespace saw { +template<typename Schema, typename Encode> +class data_server<Schema, Encode, rmt::File> final : public i_data_server<rmt::File> { +private: + ptr<remote<rmt::File>> remote_; + remote_address<rmt::File> addr_; +public: + static constexpr std::pair<uint32_t,uint32_t> class_id{schema_hash<Schema>::apply(), schema_hash<Encoding>::apply()}; + + data_server(ptr<remote<rmt::File>> remote__, ref<remote_address<rmt::File>> addr__): + remote_{remote__}, + addr_{addr__()} + {} + + ~data_server(){ + remote().deregister_data_server(*this); + } + + SAW_FORBID_MOVE(data_server); + SAW_FORBID_COPY(data_server); + + std::pair<uint32_t,uint32_t> get_class_id() const override { + return class_id; + } + + error_or<void> send(const data<Schema, Encoding>& dat, id<Schema> store_id){ + try { + } + + return make_error<err::not_implemented>(); + } + + error_or<void> allocate(data<typename meta_schema<Schema>::MetaSchema, Encoding> meta, id<Schema> store_id){ + + return make_error<err::not_implemented>(); + } + + error_or<void> erase(id<Schema> store_id){ + return make_error<err::not_implemented>(); + } + + error_or<data<Schema,Encoding>> receive(id<Schema> store_id){ + + } + +}; +} diff --git a/modules/remote/c++/transfer_loopback.hpp b/modules/remote/c++/transfer_loopback.hpp index 3eb6922..39ae402 100644 --- a/modules/remote/c++/transfer_loopback.hpp +++ b/modules/remote/c++/transfer_loopback.hpp @@ -20,7 +20,7 @@ private: ptr<remote<rmt::Loopback>> remote_; remote_address<rmt::Loopback> rmt_address_; public: - static constexpr std::pair<uint64_t,uint64_t> class_id{schema_hash<Schema>::apply(), schema_hash<Encoding>::apply()}; + static constexpr std::pair<uint32_t,uint32_t> class_id{schema_hash<Schema>::apply(), schema_hash<Encoding>::apply()}; data_server(ptr<remote<rmt::Loopback>> remote__, const remote_address<rmt::Loopback>& addr): remote_{remote__}, |