OpenCBDC Transaction Processor
|
Implementation of an agent. More...
#include <impl.hpp>
Public Types | |
enum class | state { init , begin_sent , begin_failed , function_get_sent , function_get_failed , function_get_error , function_started , function_failed , function_exception , commit_sent , commit_failed , commit_error , finish_sent , finish_failed , finish_complete , rollback_sent , rollback_failed , rollback_complete } |
States for a ticket managed by this agent. More... | |
![]() | |
enum class | error_code : uint8_t { broker_unreachable , ticket_number_assignment , function_retrieval , function_execution , commit_error , finish_error , rollback_error , retry } |
Error codes returned by agent operations. More... | |
using | exec_return_type = std::variant<return_type, error_code> |
Return type from function execution. | |
using | exec_callback_type = std::function<void(exec_return_type)> |
Callback function type with function execution result. | |
Public Member Functions | |
impl (std::shared_ptr< logging::log > logger, cbdc::parsec::config cfg, runner::interface::factory_type runner_factory, std::shared_ptr< broker::interface > broker, runtime_locking_shard::key_type function, parameter_type param, exec_callback_type result_callback, broker::lock_type initial_lock_type, bool is_readonly_run, std::shared_ptr< secp256k1_context > secp, std::shared_ptr< thread_pool > t_pool) | |
Constructor. | |
~impl () override | |
Ensures function execution is complete before destruction. | |
impl (const impl &)=delete | |
auto | operator= (const impl &) -> impl &=delete |
impl (impl &&)=delete | |
auto | operator= (impl &&) -> impl &=delete |
auto | exec () -> bool override |
Initiates function execution. | |
auto | get_ticket_number () const -> std::optional< ticket_machine::ticket_number_type > |
Returns the ticket number associated with this agent, if available. | |
auto | get_state () const -> state |
Return the state of the ticket. | |
![]() | |
virtual | ~interface ()=default |
interface (const interface &)=delete | |
auto | operator= (const interface &) -> interface &=delete |
interface (interface &&)=delete | |
auto | operator= (interface &&) -> interface &=delete |
interface (runtime_locking_shard::key_type function, parameter_type param, exec_callback_type result_callback) | |
Constructor. | |
auto | get_function () const -> runtime_locking_shard::key_type |
Return the key of the function bytecode managed by this agent. | |
auto | get_param () const -> parameter_type |
Return the function parameter managed by this agent. | |
auto | get_result_callback () const -> exec_callback_type |
Return the result callback function stored by this agent. | |
Implementation of an agent.
Definition at line 16 of file agent/impl.hpp.
|
strong |
States for a ticket managed by this agent.
Definition at line 19 of file agent/impl.hpp.
cbdc::parsec::agent::impl::impl | ( | std::shared_ptr< logging::log > | logger, |
cbdc::parsec::config | cfg, | ||
runner::interface::factory_type | runner_factory, | ||
std::shared_ptr< broker::interface > | broker, | ||
runtime_locking_shard::key_type | function, | ||
parameter_type | param, | ||
exec_callback_type | result_callback, | ||
broker::lock_type | initial_lock_type, | ||
bool | is_readonly_run, | ||
std::shared_ptr< secp256k1_context > | secp, | ||
std::shared_ptr< thread_pool > | t_pool ) |
Constructor.
logger | log instance. |
cfg | config instance. |
runner_factory | function which constructs and returns a pointer to a runner instance. |
broker | broker instance. |
function | key containing function bytecode. |
param | function parameter. |
result_callback | function to call with function execution result. |
initial_lock_type | type of lock to acquire on initial function code. |
is_readonly_run | true if the agent should skip writing state changes. |
secp | secp256k1 context. |
t_pool | shared thread pool between all agents. |
Definition at line 14 of file agent/impl.cpp.
|
override |
Ensures function execution is complete before destruction.
Definition at line 657 of file agent/impl.cpp.
|
delete |
|
delete |
|
overridevirtual |
Initiates function execution.
Implements cbdc::parsec::agent::interface.
Definition at line 38 of file agent/impl.cpp.
auto cbdc::parsec::agent::impl::get_state | ( | ) | const -> state |
auto cbdc::parsec::agent::impl::get_ticket_number | ( | ) | const -> std::optional<ticket_machine::ticket_number_type> |
Returns the ticket number associated with this agent, if available.
Definition at line 667 of file agent/impl.cpp.