OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
cbdc::parsec::runtime_locking_shard::replicated_shard_client Class Referencefinal

Client for asynchronously interacting with a raft replicated shard on the leader node of the cluster. More...

#include <replicated_shard_client.hpp>

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

Public Member Functions

 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.
 
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 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 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 function.
 
- 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

Client for asynchronously interacting with a raft replicated shard on the leader node of the cluster.

Definition at line 16 of file replicated_shard_client.hpp.

Constructor & Destructor Documentation

◆ replicated_shard_client()

cbdc::parsec::runtime_locking_shard::replicated_shard_client::replicated_shard_client ( std::shared_ptr< raft::node > raft_node)
explicit

Constructs a shard client.

Parameters
raft_nodepointer to the raft node to control.

Definition at line 14 of file replicated_shard_client.cpp.

Member Function Documentation

◆ commit()

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

Replicates a commit request in the state machine and returns the response via a callback function.

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

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

Definition at line 44 of file replicated_shard_client.cpp.

References cbdc::parsec::runtime_locking_shard::internal_error.

◆ finish()

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

Replicates a finish request in the state machine and returns the response via a callback function.

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

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

Definition at line 66 of file replicated_shard_client.cpp.

References cbdc::parsec::runtime_locking_shard::internal_error.

◆ get_tickets()

auto cbdc::parsec::runtime_locking_shard::replicated_shard_client::get_tickets ( get_tickets_callback_type result_callback) const -> bool
nodiscardoverridevirtual

Replicates a get tickets request in the state machine and returns the response via a callback function.

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

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

Definition at line 88 of file replicated_shard_client.cpp.

References cbdc::parsec::runtime_locking_shard::internal_error.

◆ prepare()

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

Replicates a prepare request in the state machine and returns the response via a callback function.

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 request replication was initiated successfully.

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

Definition at line 18 of file replicated_shard_client.cpp.

References cbdc::parsec::runtime_locking_shard::internal_error.


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