OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
replicated_shard_client.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_REPLICATED_SHARD_CLIENT_H_
7#define OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_REPLICATED_SHARD_CLIENT_H_
8
9#include "messages.hpp"
11#include "util/raft/node.hpp"
12
17 public:
21 std::shared_ptr<raft::node> raft_node);
22
30 auto prepare(ticket_number_type ticket_number,
31 broker_id_type broker_id,
32 state_type state_update,
33 callback_type result_callback) -> bool override;
34
40 auto commit(ticket_number_type ticket_number,
41 callback_type result_callback) -> bool override;
42
48 auto finish(ticket_number_type ticket_number,
49 callback_type result_callback) -> bool override;
50
56 [[nodiscard]] auto
57 get_tickets(get_tickets_callback_type result_callback) const
58 -> bool override;
59
60 private:
61 std::shared_ptr<raft::node> m_raft;
62
63 auto replicate_request(
64 const rpc::replicated_request& req,
65 const std::function<void(std::optional<rpc::replicated_response>)>&
66 result_callback) const -> bool;
67 };
68}
69
70#endif
Client for asynchronously interacting with a raft replicated shard on the leader node of the cluster.
auto finish(ticket_number_type ticket_number, callback_type result_callback) -> bool override
Replicates a finish request in the state machine and returns the response via a callback function.
auto commit(ticket_number_type ticket_number, callback_type result_callback) -> bool override
Replicates a commit request in the state machine and returns the response via a callback function.
auto get_tickets(get_tickets_callback_type result_callback) const -> bool override
Replicates a get tickets request in the state machine and returns the response via a callback functio...
replicated_shard_client(std::shared_ptr< raft::node > raft_node)
Constructs a shard client.
auto prepare(ticket_number_type ticket_number, broker_id_type broker_id, state_type state_update, callback_type result_callback) -> bool override
Replicates a prepare request in the state machine and returns the response via a callback function.
Interface for replicating internal state for prepared and committed tickets managed by a locking shar...
std::function< void(get_tickets_return_type)> get_tickets_callback_type
Callback function type for the result of a get tickets operation.
std::function< void(return_type)> callback_type
Callback function type for the result of a prepare operation.
std::unordered_map< key_type, value_type, hashing::const_sip_hash< key_type > > state_type
Type for state updates to a shard.
std::variant< replicated_prepare_request, commit_request, finish_request, replicated_get_tickets_request > replicated_request
Shard replicated state machine request type.
parsec::ticket_machine::ticket_number_type ticket_number_type
Type for a ticket number.