Couchbase C++ SDK 1.0.2 (rev. 51f4775)
Loading...
Searching...
No Matches
transactions.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright 2020-Present Couchbase, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#pragma once
19
24
25#include <functional>
26
28{
29using txn_logic = std::function<error(std::shared_ptr<attempt_context>)>;
30using async_txn_logic = std::function<error(std::shared_ptr<async_attempt_context>)>;
32
39{
40public:
41 virtual ~transactions() = default;
42
59 virtual auto run(txn_logic&& logic,
60 const transaction_options& cfg) -> std::pair<error, transaction_result> = 0;
61
62 auto run(txn_logic&& logic) -> std::pair<error, transaction_result>
63 {
64 return run(std::move(logic), {});
65 }
66
86 virtual void run(async_txn_logic&& logic,
87 async_txn_complete_logic&& complete_callback,
88 const transaction_options& cfg) = 0;
89
90 void run(async_txn_logic&& logic, async_txn_complete_logic&& complete_callback)
91 {
92 return run(std::move(logic), std::move(complete_callback), {});
93 }
94};
95} // namespace couchbase::transactions
Definition error.hxx:30
The transaction_options can be passed in to override some elements of the global transactions_config.
Definition transaction_options.hxx:37
The transactions object is used to initiate a transaction.
Definition transactions.hxx:39
virtual void run(async_txn_logic &&logic, async_txn_complete_logic &&complete_callback, const transaction_options &cfg)=0
Run an asynchronous transaction.
virtual auto run(txn_logic &&logic, const transaction_options &cfg) -> std::pair< error, transaction_result >=0
Run a blocking transaction.
void run(async_txn_logic &&logic, async_txn_complete_logic &&complete_callback)
Definition transactions.hxx:90
auto run(txn_logic &&logic) -> std::pair< error, transaction_result >
Definition transactions.hxx:62
Definition transactions.hxx:28
std::function< error(std::shared_ptr< async_attempt_context >)> async_txn_logic
Definition transactions.hxx:30
std::function< error(std::shared_ptr< attempt_context >)> txn_logic
Definition transactions.hxx:29
std::function< void(error, transaction_result)> async_txn_complete_logic
Definition transactions.hxx:31
@ error
Indicates that the ping operation failed.
Results of a transaction.
Definition transaction_result.hxx:29