OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
parsec/runtime_locking_shard/client.hpp
Go to the documentation of this file.
1// Copyright (c) 2021 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_CLIENT_H_
7#define OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_CLIENT_H_
8
9#include "interface.hpp"
10#include "messages.hpp"
12
15 class client : public interface {
16 public:
20 explicit client(std::vector<network::endpoint_t> endpoints);
21
22 client() = delete;
23 ~client() override = default;
24 client(const client&) = delete;
25 auto operator=(const client&) -> client& = delete;
26 client(client&&) = delete;
27 auto operator=(client&&) -> client& = delete;
28
31 auto init() -> bool;
32
41 auto try_lock(ticket_number_type ticket_number,
42 broker_id_type broker_id,
43 key_type key,
44 lock_type locktype,
45 bool first_lock,
46 try_lock_callback_type result_callback) -> bool override;
47
54 auto prepare(ticket_number_type ticket_number,
55 broker_id_type broker_id,
56 state_update_type state_update,
57 prepare_callback_type result_callback) -> bool override;
58
63 auto commit(ticket_number_type ticket_number,
64 commit_callback_type result_callback) -> bool override;
65
70 auto rollback(ticket_number_type ticket_number,
71 rollback_callback_type result_callback) -> bool override;
72
77 auto finish(ticket_number_type ticket_number,
78 finish_callback_type result_callback) -> bool override;
79
85 auto get_tickets(broker_id_type broker_id,
86 get_tickets_callback_type result_callback)
87 -> bool override;
88
89 private:
90 std::unique_ptr<cbdc::rpc::tcp_client<request, response>> m_client;
91 };
92}
93
94#endif
Buffer to store and retrieve byte data.
Definition buffer.hpp:15
std::function< void(prepare_return_type)> prepare_callback_type
Callback function type for the result of a prepare operation.
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(rollback_return_type)> rollback_callback_type
Callback function type for the result of a rollback operation.
std::function< void(finish_return_type)> finish_callback_type
Callback function type for the result of a finish operation.
std::function< void(try_lock_return_type)> try_lock_callback_type
Function type for try lock operation results.
std::function< void(commit_return_type)> commit_callback_type
Callback function type for the result of a commit operation.
auto init() -> bool
Initializes the underlying TCP client.
auto prepare(ticket_number_type ticket_number, broker_id_type broker_id, state_update_type state_update, prepare_callback_type result_callback) -> bool override
Requests a prepare operation from the remote shard.
auto commit(ticket_number_type ticket_number, commit_callback_type result_callback) -> bool override
Requests a commit operation from the remote shard.
auto get_tickets(broker_id_type broker_id, get_tickets_callback_type result_callback) -> bool override
Requests a get tickets operation from the remote shard.
auto try_lock(ticket_number_type ticket_number, broker_id_type broker_id, key_type key, lock_type locktype, bool first_lock, try_lock_callback_type result_callback) -> bool override
Requests a try lock operation from the remote shard.
auto operator=(const client &) -> client &=delete
auto finish(ticket_number_type ticket_number, finish_callback_type result_callback) -> bool override
Requests a finish operation from the remote shard.
auto operator=(client &&) -> client &=delete
auto rollback(ticket_number_type ticket_number, rollback_callback_type result_callback) -> bool override
Requests a rollback operation from the remote shard.
parsec::ticket_machine::ticket_number_type ticket_number_type
Type for a ticket number.
std:: unordered_map< key_type, value_type, hashing::const_sip_hash< key_type > > state_update_type
Type for state updates to a shard. A map of keys and their new values.