OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
parsec/agent/interface.hpp
Go to the documentation of this file.
1// Copyright (c) 2021 MIT Digital Currency Initiative,
2// Federal Reserve Bank of Boston
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_INTERFACE_H_
7#define OPENCBDC_TX_SRC_PARSEC_AGENT_INTERFACE_H_
8
10
11namespace cbdc::parsec::agent {
16
19 class interface {
20 public:
21 virtual ~interface() = default;
22
23 interface(const interface&) = delete;
24 auto operator=(const interface&) -> interface& = delete;
25 interface(interface&&) = delete;
26 auto operator=(interface&&) -> interface& = delete;
27
47
50 using exec_return_type = std::variant<return_type, error_code>;
52 using exec_callback_type = std::function<void(exec_return_type)>;
53
59 parameter_type param,
60 exec_callback_type result_callback);
61
65 virtual auto exec() -> bool = 0;
66
69 [[nodiscard]] auto get_function() const
70 -> runtime_locking_shard::key_type;
71
74 [[nodiscard]] auto get_param() const -> parameter_type;
75
78 [[nodiscard]] auto get_result_callback() const -> exec_callback_type;
79
80 private:
81 runtime_locking_shard::key_type m_function;
82 parameter_type m_param;
83 exec_callback_type m_result_callback;
84 };
85}
86
87#endif
Buffer to store and retrieve byte data.
Definition buffer.hpp:15
virtual auto exec() -> bool=0
Executes the function managed by this agent with the given parameter.
virtual ~interface()=default
auto get_result_callback() const -> exec_callback_type
Return the result callback function stored by this agent.
interface(interface &&)=delete
interface(const interface &)=delete
std::variant< return_type, error_code > exec_return_type
Return type from function execution.
error_code
Error codes returned by agent operations.
@ retry
Transient error, execution should be retried.
@ commit_error
Error committing the function state updates.
@ function_execution
Error during function execution.
@ finish_error
Error finishing the ticket.
@ function_retrieval
Error retrieving function bytecode.
@ broker_unreachable
Broker was unreachable.
@ ticket_number_assignment
Ticket number assignment failed.
auto operator=(const interface &) -> interface &=delete
std::function< void(exec_return_type)> exec_callback_type
Callback function type with function execution result.
auto operator=(interface &&) -> interface &=delete
auto get_param() const -> parameter_type
Return the function parameter managed by this agent.
auto get_function() const -> runtime_locking_shard::key_type
Return the key of the function bytecode managed by this agent.
broker::state_update_type return_type
Type returned after function execution.
runtime_locking_shard::state_update_type state_update_type
Shard state updates type.
@ buffer
A singular RLP value (byte array)