OpenCBDC Transaction Processor
|
Implementation of the replicated shard interface. More...
#include <replicated_shard.hpp>
Public Member Functions | |
auto | prepare (ticket_number_type ticket_number, broker_id_type broker_id, state_type state_update, callback_type result_callback) -> bool override |
Stores a prepare request for a ticket in the state machine. | |
auto | commit (ticket_number_type ticket_number, callback_type result_callback) -> bool override |
Stores a commit request in the state machine. | |
auto | finish (ticket_number_type ticket_number, callback_type result_callback) -> bool override |
Stores a finish request in the state machine. | |
auto | get_tickets (get_tickets_callback_type result_callback) const -> bool override |
Retrieves unfinished tickets from the state machine. | |
auto | get_state () const -> state_type |
Return the keys and values stored by the shard. | |
![]() | |
virtual | ~replicated_shard_interface ()=default |
replicated_shard_interface ()=default | |
replicated_shard_interface (const replicated_shard_interface &)=default | |
auto | operator= (const replicated_shard_interface &) -> replicated_shard_interface &=default |
replicated_shard_interface (replicated_shard_interface &&)=default | |
auto | operator= (replicated_shard_interface &&) -> replicated_shard_interface &=default |
Additional Inherited Members | |
![]() | |
enum class | error_code : uint8_t { unknown_ticket , internal_error } |
Error codes returned by class methods. More... | |
enum class | ticket_state : uint8_t { prepared , committed } |
Ticket states returned by shards for broker recovery purposes. More... | |
using | state_type |
Type for state updates to a shard. | |
using | tickets_type = std::unordered_map<ticket_number_type, ticket_type> |
Type for the tickets list returned by the state machine. | |
using | return_type = std::optional<error_code> |
Return type from a prepare operation. An error, if applicable. | |
using | callback_type = std::function<void(return_type)> |
Callback function type for the result of a prepare operation. | |
using | get_tickets_return_type = std::variant<tickets_type, error_code> |
Return type from a get tickets operation. | |
using | get_tickets_callback_type = std::function<void(get_tickets_return_type)> |
Callback function type for the result of a get tickets operation. | |
Implementation of the replicated shard interface.
Stores the shard state and unfinished ticket in memory. Thread-safe.
Definition at line 16 of file replicated_shard.hpp.
|
overridevirtual |
Stores a commit request in the state machine.
ticket_number | ticket to commit. |
result_callback | function to call with commit result. |
Implements cbdc::parsec::runtime_locking_shard::replicated_shard_interface.
Definition at line 25 of file replicated_shard.cpp.
References cbdc::parsec::runtime_locking_shard::committed, and cbdc::parsec::runtime_locking_shard::unknown_ticket.
|
overridevirtual |
Stores a finish request in the state machine.
ticket_number | ticket to finish. |
result_callback | function to call with finish result. |
Implements cbdc::parsec::runtime_locking_shard::replicated_shard_interface.
Definition at line 44 of file replicated_shard.cpp.
auto cbdc::parsec::runtime_locking_shard::replicated_shard::get_state | ( | ) | const -> state_type |
Return the keys and values stored by the shard.
Definition at line 65 of file replicated_shard.cpp.
|
overridevirtual |
Retrieves unfinished tickets from the state machine.
result_callback | function to call with the tickets held by the state machine. |
Implements cbdc::parsec::runtime_locking_shard::replicated_shard_interface.
Definition at line 55 of file replicated_shard.cpp.
|
overridevirtual |
Stores a prepare request for a ticket in the state machine.
ticket_number | ticket to prepare. |
broker_id | broker managing the ticket. |
state_update | keys and values to update after commit. |
result_callback | function to call with prepare result. |
Implements cbdc::parsec::runtime_locking_shard::replicated_shard_interface.
Definition at line 9 of file replicated_shard.cpp.
References cbdc::parsec::runtime_locking_shard::prepared.