OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
parsec/runtime_locking_shard/server.hpp
Go to the documentation of this file.
1// Copyright (c) 2022 MIT Digital Currency Initiative,
2// Federal Reserve Bank of Boston
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#ifndef OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_SERVER_H_
7#define OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_SERVER_H_
8
9#include "interface.hpp"
10#include "messages.hpp"
13
16 class server {
17 public:
24 server(
25 std::shared_ptr<logging::log> logger,
26 std::shared_ptr<interface> impl,
27 std::shared_ptr<replicated_shard_interface> repl,
29
30 private:
31 std::shared_ptr<logging::log> m_log;
32 std::shared_ptr<interface> m_impl;
33 std::shared_ptr<replicated_shard_interface> m_repl;
34 std::unique_ptr<cbdc::rpc::async_server<request, response>> m_srv;
35
36 using callback_type = std::function<void(std::optional<response>)>;
37
38 auto handler_callback(const request& req, callback_type callback)
39 -> bool;
40
41 void handle_prepare(interface::prepare_return_type ret,
42 const rpc::prepare_request& msg,
43 const callback_type& callback);
44
45 void handle_commit(replicated_shard_interface::return_type ret,
47 const callback_type& callback);
48
49 void do_rollback(replicated_shard_interface::return_type ret,
51 const callback_type& callback);
52
55 const callback_type& callback);
56 };
57}
58
59#endif
Implementation of a runtime locking shard.
std::optional< shard_error > prepare_return_type
Return type from a prepare operation. An error, if applicable.
std::optional< error_code > return_type
Return type from a prepare operation. An error, if applicable.
server(std::shared_ptr< logging::log > logger, std::shared_ptr< interface > impl, std::shared_ptr< replicated_shard_interface > repl, std::unique_ptr< cbdc::rpc::async_server< request, response > > srv)
Constructor.
Generic asynchronous RPC server.
std::variant< try_lock_request, prepare_request, commit_request, rollback_request, finish_request, get_tickets_request > request
RPC request message type.