CCF
Loading...
Searching...
No Matches
historical_queries_adapter.h
Go to the documentation of this file.
1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the Apache 2.0 License.
3#pragma once
4
8#include "ccf/node_context.h"
9#include "ccf/tx_id.h"
10#include "ccf/tx_status.h"
11
12namespace ccf::kv
13{
14 class Consensus;
15}
16
18{
19 using CheckAvailability = std::function<bool(
20 ccf::View view, ccf::SeqNo seqno, std::string& error_reason)>;
21
23 std::function<void(ccf::endpoints::EndpointContext& args, StatePtr state)>;
24
25 using HandleReadOnlyHistoricalQuery = std::function<void(
27
29
30 using CommandTxIDExtractor = std::function<std::optional<ccf::TxID>(
32
33 using ReadOnlyTxIDExtractor = std::function<std::optional<ccf::TxID>(
35
37 std::function<std::optional<ccf::TxID>(endpoints::EndpointContext& args)>;
38
39 std::optional<ccf::TxID> txid_from_header(
41
50
51 using ErrorHandler = std::function<void(
53 std::string reason,
55
56 using ReadOnlyErrorHandler = std::function<void(
58 std::string reason,
60
63 std::string reason,
65
67 {
68 Error,
70 Invalid,
71 Valid
72 };
73
75 ccf::View view, ccf::SeqNo seqno, std::string& error_reason)>;
76
81 std::string& error_reason);
82
83 CCF_DEPRECATED("Replaced by _v4")
84 ccf::endpoints::EndpointFunction adapter_v3(
85 const HandleHistoricalQuery& f,
86 ccf::AbstractNodeContext& node_context,
87 const CheckHistoricalTxStatus& available,
88 const TxIDExtractor& extractor = txid_from_header);
89
90 CCF_DEPRECATED("Replaced by _v4")
91 ccf::endpoints::ReadOnlyEndpointFunction read_only_adapter_v3(
93 ccf::AbstractNodeContext& node_context,
94 const CheckHistoricalTxStatus& available,
95 const ReadOnlyTxIDExtractor& extractor = txid_from_header);
96
97 CCF_DEPRECATED("Replaced by _v4")
98 ccf::endpoints::EndpointFunction read_write_adapter_v3(
100 ccf::AbstractNodeContext& node_context,
101 const CheckHistoricalTxStatus& available,
102 const TxIDExtractor& extractor = txid_from_header);
103
104 ccf::endpoints::ReadOnlyEndpointFunction read_only_adapter_v4(
106 ccf::AbstractNodeContext& node_context,
107 const CheckHistoricalTxStatus& available,
108 const ReadOnlyTxIDExtractor& extractor = txid_from_header,
110
111 ccf::endpoints::EndpointFunction read_write_adapter_v4(
113 ccf::AbstractNodeContext& node_context,
114 const CheckHistoricalTxStatus& available,
115 const TxIDExtractor& extractor = txid_from_header,
116 const ErrorHandler& ehandler = default_error_handler);
117}
#define CCF_DEPRECATED(reason)
Definition ccf_deprecated.h:5
Definition kv_types.h:436
Definition historical_queries_adapter.h:18
std::function< void(HistoricalQueryErrorCode err, std::string reason, endpoints::ReadOnlyEndpointContext &args)> ReadOnlyErrorHandler
Definition historical_queries_adapter.h:59
HandleReadWriteHistoricalQuery HandleHistoricalQuery
Definition historical_queries_adapter.h:28
std::function< std::optional< ccf::TxID >(endpoints::CommandEndpointContext &args)> CommandTxIDExtractor
Definition historical_queries_adapter.h:31
std::function< std::optional< ccf::TxID >(endpoints::ReadOnlyEndpointContext &args)> ReadOnlyTxIDExtractor
Definition historical_queries_adapter.h:34
HistoricalQueryErrorCode
Definition historical_queries_adapter.h:43
std::shared_ptr< State > StatePtr
Definition historical_queries_interface.h:41
ccf::endpoints::EndpointFunction read_write_adapter_v3(const HandleReadWriteHistoricalQuery &f, ccf::AbstractNodeContext &node_context, const CheckHistoricalTxStatus &available, const TxIDExtractor &extractor=txid_from_header)
Definition historical_queries_adapter.cpp:449
void default_error_handler(HistoricalQueryErrorCode err, std::string reason, endpoints::CommandEndpointContext &args)
Definition historical_queries_adapter.cpp:312
std::optional< ccf::TxID > txid_from_header(endpoints::CommandEndpointContext &args)
Definition historical_queries_adapter.cpp:279
std::function< void(HistoricalQueryErrorCode err, std::string reason, endpoints::EndpointContext &args)> ErrorHandler
Definition historical_queries_adapter.h:54
std::function< void(ccf::endpoints::ReadOnlyEndpointContext &args, StatePtr state)> HandleReadOnlyHistoricalQuery
Definition historical_queries_adapter.h:26
std::function< void(ccf::endpoints::EndpointContext &args, StatePtr state)> HandleReadWriteHistoricalQuery
Definition historical_queries_adapter.h:23
std::function< HistoricalTxStatus(ccf::View view, ccf::SeqNo seqno, std::string &error_reason)> CheckHistoricalTxStatus
Definition historical_queries_adapter.h:75
ccf::endpoints::ReadOnlyEndpointFunction read_only_adapter_v3(const HandleReadOnlyHistoricalQuery &f, ccf::AbstractNodeContext &node_context, const CheckHistoricalTxStatus &available, const ReadOnlyTxIDExtractor &extractor=txid_from_header)
Definition historical_queries_adapter.cpp:436
HistoricalTxStatus
Definition historical_queries_adapter.h:67
ccf::endpoints::EndpointFunction read_write_adapter_v4(const HandleReadWriteHistoricalQuery &f, ccf::AbstractNodeContext &node_context, const CheckHistoricalTxStatus &available, const TxIDExtractor &extractor=txid_from_header, const ErrorHandler &ehandler=default_error_handler)
Definition historical_queries_adapter.cpp:618
std::function< bool(ccf::View view, ccf::SeqNo seqno, std::string &error_reason)> CheckAvailability
Definition historical_queries_adapter.h:20
ccf::endpoints::EndpointFunction adapter_v3(const HandleHistoricalQuery &f, ccf::AbstractNodeContext &node_context, const CheckHistoricalTxStatus &available, const TxIDExtractor &extractor=txid_from_header)
Definition historical_queries_adapter.cpp:424
HistoricalTxStatus is_tx_committed_v2(ccf::kv::Consensus *consensus, ccf::View view, ccf::SeqNo seqno, std::string &error_reason)
Definition historical_queries_adapter.cpp:364
std::function< std::optional< ccf::TxID >(endpoints::EndpointContext &args)> TxIDExtractor
Definition historical_queries_adapter.h:37
ccf::endpoints::ReadOnlyEndpointFunction read_only_adapter_v4(const HandleReadOnlyHistoricalQuery &f, ccf::AbstractNodeContext &node_context, const CheckHistoricalTxStatus &available, const ReadOnlyTxIDExtractor &extractor=txid_from_header, const ReadOnlyErrorHandler &ehandler=default_error_handler)
Definition historical_queries_adapter.cpp:604
Definition app_interface.h:19
Definition app_interface.h:14
view
Definition signatures.h:54
seqno
Definition signatures.h:54
uint64_t View
Definition tx_id.h:23
uint64_t SeqNo
Definition tx_id.h:36
Definition consensus_types.h:23
Definition node_context.h:12
Definition endpoint_context.h:24
Definition endpoint_context.h:55
Definition endpoint_context.h:70