diff options
Diffstat (limited to 'modules/codec/c++/rpc.hpp')
-rw-r--r-- | modules/codec/c++/rpc.hpp | 94 |
1 files changed, 79 insertions, 15 deletions
diff --git a/modules/codec/c++/rpc.hpp b/modules/codec/c++/rpc.hpp index 63ec014..9f59455 100644 --- a/modules/codec/c++/rpc.hpp +++ b/modules/codec/c++/rpc.hpp @@ -1,34 +1,98 @@ #pragma once namespace saw { + +/** + * + */ +template<typename T, typename Remote> +class remote_data { +private: + id<T> id_; +public: + remote_data(const id<T>& id): + id_{id} + {} + + /** + * Wait until data arrives + */ + error_or<data<T>> wait(wait_scope& wait); + + /** + * Asynchronously wait for a result + */ + conveyor<data<T>> on_receive(); +}; + /** + * Client RPC reference structure */ template<typename T, typename Iface> class rpc_client { - template<typename... IdT> - struct request { - private: - std::tuple<id<IdT>...> ids_; - public: - error_or<data<schema::Tuple<IdT>...>> wait(); - }; + /** + * request the data from the remote + */ + template<typename IdT> + remote_data<IdT> request_data(id<IdT> data); - template<typename... IdT> - request<IdT...> request_data(id<IdT>... data); + /** + * Determine type based on Name + */ + template<string_literal Name> + error_or< + id< + typename schema_member_type<Name, Iface>::type + > + > call(data_or_id<Input> inp); }; +/** + * Implementation of a remote server on the backend + */ template<typename T, typename Iface> class rpc_server { +private: + interface<Iface> iface_; +public: + rpc_server(interface<Iface> iface): + iface_{std::move(iface)} + {} }; +/** + * Representation of a remote. + * Partially similar to a network address + */ template<typename T> -class remote { - static_assert(always_false<T>, "Type of remote not supported"); +class remote_address { + static_assert(always_false<T>, "Type of remote not supported"); + + +}; + +/** + * Reference Backend structure + */ +template<typename T> +class remote_context { + static_assert(always_false<T>, "Type of backend not supported"); + + /** + * Resolves an address on the remote + */ + conveyor<remote_address<T>> resolve_address(); - template<typename Iface> - rpc_client<T,Iface> connect(); + /** + * Connect to a remote + */ + template<typename Iface> + conveyor<rpc_client<T,Iface>> connect(const remote_address<T>& addr); - template<typename Iface> - rpc_server<T,Iface> listen(network& net); + /** + * Start listening + */ + template<typename Iface> + rpc_server<T,Iface> listen(); }; } |