OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
cbdc::parsec::runtime_locking_shard::replicated_shard_interface Class Referenceabstract

Interface for replicating internal state for prepared and committed tickets managed by a locking shard. More...

#include <replicated_shard_interface.hpp>

Inheritance diagram for cbdc::parsec::runtime_locking_shard::replicated_shard_interface:

Data Structures

struct  ticket_type
 Ticket date stored in the replicated state machine. More...
 

Public Types

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.
 

Public Member Functions

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
 
virtual auto prepare (ticket_number_type ticket_number, broker_id_type broker_id, state_type state_update, callback_type result_callback) -> bool=0
 Stores a prepare request for a ticket in the state machine.
 
virtual auto commit (ticket_number_type ticket_number, callback_type result_callback) -> bool=0
 Stores a commit request in the state machine.
 
virtual auto finish (ticket_number_type ticket_number, callback_type result_callback) -> bool=0
 Stores a finish request in the state machine.
 
virtual auto get_tickets (get_tickets_callback_type result_callback) const -> bool=0
 Retrieves unfinished tickets from the state machine.
 

Detailed Description

Interface for replicating internal state for prepared and committed tickets managed by a locking shard.

Definition at line 14 of file replicated_shard_interface.hpp.

Member Typedef Documentation

◆ callback_type

Callback function type for the result of a prepare operation.

Definition at line 54 of file replicated_shard_interface.hpp.

◆ get_tickets_callback_type

Callback function type for the result of a get tickets operation.

Definition at line 99 of file replicated_shard_interface.hpp.

◆ get_tickets_return_type

Return type from a get tickets operation.

Either a map of ticket states or an error code.

Definition at line 97 of file replicated_shard_interface.hpp.

◆ return_type

Return type from a prepare operation. An error, if applicable.

Definition at line 52 of file replicated_shard_interface.hpp.

◆ state_type

Initial value:
std::unordered_map<key_type,
hashing::const_sip_hash<key_type>>

Type for state updates to a shard.

A map of keys and their new values.

Definition at line 44 of file replicated_shard_interface.hpp.

◆ tickets_type

Type for the tickets list returned by the state machine.

Definition at line 49 of file replicated_shard_interface.hpp.

Member Enumeration Documentation

◆ error_code

Error codes returned by class methods.

Enumerator
unknown_ticket 

Requested ticket does not exist.

internal_error 

Internal error preventing processing.

Definition at line 17 of file replicated_shard_interface.hpp.

◆ ticket_state

Ticket states returned by shards for broker recovery purposes.

Enumerator
prepared 

Prepared, holds locks.

committed 

Committed, not holding any locks.

Definition at line 25 of file replicated_shard_interface.hpp.

Constructor & Destructor Documentation

◆ ~replicated_shard_interface()

virtual cbdc::parsec::runtime_locking_shard::replicated_shard_interface::~replicated_shard_interface ( )
virtualdefault

◆ replicated_shard_interface() [1/3]

cbdc::parsec::runtime_locking_shard::replicated_shard_interface::replicated_shard_interface ( )
default

◆ replicated_shard_interface() [2/3]

cbdc::parsec::runtime_locking_shard::replicated_shard_interface::replicated_shard_interface ( const replicated_shard_interface & )
default

◆ replicated_shard_interface() [3/3]

cbdc::parsec::runtime_locking_shard::replicated_shard_interface::replicated_shard_interface ( replicated_shard_interface && )
default

Member Function Documentation

◆ commit()

virtual auto cbdc::parsec::runtime_locking_shard::replicated_shard_interface::commit ( ticket_number_type ticket_number,
callback_type result_callback ) -> bool
pure virtual

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.

Implemented in cbdc::parsec::runtime_locking_shard::replicated_shard, and cbdc::parsec::runtime_locking_shard::replicated_shard_client.

◆ finish()

virtual auto cbdc::parsec::runtime_locking_shard::replicated_shard_interface::finish ( ticket_number_type ticket_number,
callback_type result_callback ) -> bool
pure virtual

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.

Implemented in cbdc::parsec::runtime_locking_shard::replicated_shard, and cbdc::parsec::runtime_locking_shard::replicated_shard_client.

◆ get_tickets()

virtual auto cbdc::parsec::runtime_locking_shard::replicated_shard_interface::get_tickets ( get_tickets_callback_type result_callback) const -> bool
nodiscardpure virtual

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.

Implemented in cbdc::parsec::runtime_locking_shard::replicated_shard, and cbdc::parsec::runtime_locking_shard::replicated_shard_client.

◆ operator=() [1/2]

auto cbdc::parsec::runtime_locking_shard::replicated_shard_interface::operator= ( const replicated_shard_interface & ) -> replicated_shard_interface &=default
default

◆ operator=() [2/2]

auto cbdc::parsec::runtime_locking_shard::replicated_shard_interface::operator= ( replicated_shard_interface && ) -> replicated_shard_interface &=default
default

◆ prepare()

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

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.

Implemented in cbdc::parsec::runtime_locking_shard::replicated_shard, and cbdc::parsec::runtime_locking_shard::replicated_shard_client.


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