OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
cbdc::parsec::runtime_locking_shard::replicated_shard Class Reference

Implementation of the replicated shard interface. More...

#include <replicated_shard.hpp>

Inheritance diagram for cbdc::parsec::runtime_locking_shard::replicated_shard:
Collaboration diagram for cbdc::parsec::runtime_locking_shard::replicated_shard:

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.
 
- Public Member Functions inherited from cbdc::parsec::runtime_locking_shard::replicated_shard_interface
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

- Public Types inherited from cbdc::parsec::runtime_locking_shard::replicated_shard_interface
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.
 

Detailed Description

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.

Member Function Documentation

◆ commit()

auto cbdc::parsec::runtime_locking_shard::replicated_shard::commit ( ticket_number_type ticket_number,
callback_type result_callback ) -> bool
overridevirtual

Stores a commit request in the state machine.

Parameters
ticket_numberticket to commit.
result_callbackfunction to call with commit result.
Returns
true if operation was initiated successfully.
true.

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.

◆ finish()

auto cbdc::parsec::runtime_locking_shard::replicated_shard::finish ( ticket_number_type ticket_number,
callback_type result_callback ) -> bool
overridevirtual

Stores a finish request in the state machine.

Parameters
ticket_numberticket to finish.
result_callbackfunction to call with finish result.
Returns
true if operation was initiated successfully.
true.

Implements cbdc::parsec::runtime_locking_shard::replicated_shard_interface.

Definition at line 44 of file replicated_shard.cpp.

◆ get_state()

auto cbdc::parsec::runtime_locking_shard::replicated_shard::get_state ( ) const -> state_type

Return the keys and values stored by the shard.

Returns
shard state.

Definition at line 65 of file replicated_shard.cpp.

◆ get_tickets()

auto cbdc::parsec::runtime_locking_shard::replicated_shard::get_tickets ( get_tickets_callback_type result_callback) const -> bool
overridevirtual

Retrieves unfinished tickets from the state machine.

Parameters
result_callbackfunction to call with the tickets held by the state machine.
Returns
true if operation was initiated successfully.
true.

Implements cbdc::parsec::runtime_locking_shard::replicated_shard_interface.

Definition at line 55 of file replicated_shard.cpp.

◆ prepare()

auto cbdc::parsec::runtime_locking_shard::replicated_shard::prepare ( ticket_number_type ticket_number,
broker_id_type broker_id,
state_type state_update,
callback_type result_callback ) -> bool
overridevirtual

Stores a prepare request for a ticket in the state machine.

Parameters
ticket_numberticket to prepare.
broker_idbroker managing the ticket.
state_updatekeys and values to update after commit.
result_callbackfunction to call with prepare result.
Returns
true if operation was initiated successfully.
true.

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.


The documentation for this class was generated from the following files: