6#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_IMPL_H_
7#define OPENCBDC_TX_SRC_PARSEC_AGENT_IMPL_H_
73 impl(std::shared_ptr<logging::log> logger,
76 std::shared_ptr<broker::interface> broker,
82 std::shared_ptr<secp256k1_context> secp,
83 std::shared_ptr<thread_pool> t_pool);
95 auto exec() ->
bool override;
101 -> std::optional<ticket_machine::ticket_number_type>;
108 std::shared_ptr<logging::log> m_log;
110 runner::
interface::factory_type m_runner_factory;
111 std::shared_ptr<broker::
interface> m_broker;
112 std::optional<ticket_machine::ticket_number_type> m_ticket_number;
114 std::unique_ptr<runner::
interface> m_runner;
116 bool m_permanent_error{
false};
117 mutable std::recursive_mutex m_mut;
119 bool m_is_readonly_run;
120 std::shared_ptr<secp256k1_context> m_secp;
121 std::shared_ptr<thread_pool> m_threads;
122 std::optional<hash_t> m_tx_id;
123 bool m_wounded{
false};
125 bool m_restarted{
false};
144 void do_rollback(
bool finish);
161 void handle_try_lock_response(
Buffer to store and retrieve byte data.
Implementation of an agent.
state
States for a ticket managed by this agent.
@ begin_sent
Begin request sent to broker.
@ function_get_failed
Function bytecode lock request failed.
@ commit_error
Broker error during commit request.
@ function_get_error
Broker error during function bytecode lock.
@ rollback_failed
Rollback request failed.
@ function_get_sent
Function bytecode lock sent to broker.
@ function_started
Function execution started.
@ commit_failed
Commit request failed.
@ finish_failed
Finish request failed.
@ function_exception
Function error during execution.
@ finish_complete
Finish complete.
@ commit_sent
Commit request sent to broker.
@ rollback_sent
Rollback request sent to broker.
@ rollback_complete
Rollback complete.
@ finish_sent
Finish request sent to broker.
@ begin_failed
Begin request failed.
@ function_failed
Function execution failed.
auto exec() -> bool override
Initiates function execution.
auto get_state() const -> state
Return the state of the ticket.
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.
auto operator=(const impl &) -> impl &=delete
impl(const impl &)=delete
~impl() override
Ensures function execution is complete before destruction.
auto get_ticket_number() const -> std::optional< ticket_machine::ticket_number_type >
Returns the ticket number associated with this agent, if available.
auto operator=(impl &&) -> impl &=delete
std::variant< return_type, error_code > exec_return_type
Return type from function execution.
std::function< void(exec_return_type)> exec_callback_type
Callback function type with function execution result.
std::function< std::unique_ptr< interface >( std::shared_ptr< logging::log > logger, const cbdc::parsec::config &cfg, runtime_locking_shard::value_type function, parameter_type param, bool is_readonly_run, runner::interface::run_callback_type result_callback, runner::interface::try_lock_callback_type try_lock_callback, std::shared_ptr< secp256k1_context >, std::shared_ptr< thread_pool > t_pool, ticket_number_type ticket_number)> factory_type
Factory function type for instantiating new runners.
std::variant< runtime_locking_shard::state_update_type, error_code > run_return_type
Return type from executing a function.
std::variant< value_type, error_code, runtime_locking_shard::shard_error > try_lock_return_type
Return type from a try lock operation.
std::optional< std::variant< error_code, runtime_locking_shard::shard_error > > commit_return_type
Return type from a commit operation.
std::optional< error_code > finish_return_type
Return type from a finish operation.
std::variant< ticket_number_type, error_code > ticketnum_or_errcode_type
Return type from a begin operation.
std::function< void(try_lock_return_type)> try_lock_callback_type
Callback function type for a try lock operation.
std::optional< std::variant< error_code, runtime_locking_shard::error_code > > rollback_return_type
Return type from a rollback operation.
runtime_locking_shard::value_type value_type
Shard value type.
runtime_locking_shard::key_type key_type
Shard key type.
std:: unordered_map< key_type, lock_type, hashing::const_sip_hash< key_type > > held_locks_set_type
Set of held locks.
runtime_locking_shard::lock_type lock_type
Shard lock type.
lock_type
Types of key lock supported by shards.
Configuration parameters for a phase two system.