OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
cbdc::parsec::agent::impl Class Reference

Implementation of an agent. More...

#include <impl.hpp>

Inheritance diagram for cbdc::parsec::agent::impl:
Collaboration diagram for cbdc::parsec::agent::impl:

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...
 
- Public Types inherited from cbdc::parsec::agent::interface
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.
 
- Public Member Functions inherited from cbdc::parsec::agent::interface
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.
 

Detailed Description

Implementation of an agent.

Definition at line 16 of file agent/impl.hpp.

Member Enumeration Documentation

◆ state

States for a ticket managed by this agent.

Enumerator
init 

Initial state.

begin_sent 

Begin request sent to broker.

begin_failed 

Begin request failed.

function_get_sent 

Function bytecode lock sent to broker.

function_get_failed 

Function bytecode lock request failed.

function_get_error 

Broker error during function bytecode lock.

function_started 

Function execution started.

function_failed 

Function execution failed.

function_exception 

Function error during execution.

commit_sent 

Commit request sent to broker.

commit_failed 

Commit request failed.

commit_error 

Broker error during commit request.

finish_sent 

Finish request sent to broker.

finish_failed 

Finish request failed.

finish_complete 

Finish complete.

rollback_sent 

Rollback request sent to broker.

rollback_failed 

Rollback request failed.

rollback_complete 

Rollback complete.

Definition at line 19 of file agent/impl.hpp.

Constructor & Destructor Documentation

◆ impl() [1/3]

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.

Parameters
loggerlog instance.
cfgconfig instance.
runner_factoryfunction which constructs and returns a pointer to a runner instance.
brokerbroker instance.
functionkey containing function bytecode.
paramfunction parameter.
result_callbackfunction to call with function execution result.
initial_lock_typetype of lock to acquire on initial function code.
is_readonly_runtrue if the agent should skip writing state changes.
secpsecp256k1 context.
t_poolshared thread pool between all agents.

Definition at line 14 of file agent/impl.cpp.

◆ ~impl()

cbdc::parsec::agent::impl::~impl ( )
override

Ensures function execution is complete before destruction.

Definition at line 657 of file agent/impl.cpp.

◆ impl() [2/3]

cbdc::parsec::agent::impl::impl ( const impl & )
delete

◆ impl() [3/3]

cbdc::parsec::agent::impl::impl ( impl && )
delete

Member Function Documentation

◆ exec()

auto cbdc::parsec::agent::impl::exec ( ) -> bool
overridevirtual

Initiates function execution.

Returns
true.

Implements cbdc::parsec::agent::interface.

Definition at line 38 of file agent/impl.cpp.

◆ get_state()

auto cbdc::parsec::agent::impl::get_state ( ) const -> state

Return the state of the ticket.

Returns
ticket state.

Definition at line 673 of file agent/impl.cpp.

◆ get_ticket_number()

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.

Returns
ticket number, or std::nullopt if no ticket number has been assigned yet.

Definition at line 667 of file agent/impl.cpp.

◆ operator=() [1/2]

auto cbdc::parsec::agent::impl::operator= ( const impl & ) -> impl &=delete
delete

◆ operator=() [2/2]

auto cbdc::parsec::agent::impl::operator= ( impl && ) -> impl &=delete
delete

References init.


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