@@ -33,6 +33,7 @@ namespace impl {
3333struct Stats ;
3434struct TableSettings ;
3535class Driver ;
36+ template <typename Settings = OperationSettings>
3637struct RequestContext ;
3738enum class IsStreaming : bool {};
3839} // namespace impl
@@ -48,7 +49,8 @@ using DescribeTableSettings = NYdb::NTable::TDescribeTableSettings;
4849using DropTableSettings = NYdb::NTable::TDropTableSettings;
4950using ScanQuerySettings = NYdb::NTable::TStreamExecScanQuerySettings;
5051
51- // / @brief A dynamic transaction name for @see TableClient::Begin.
52+ // / @brief A dynamic transaction name for @see TableClient::Begin or
53+ // / @see TableClient::RetryTx.
5254// /
5355// / @warning Make sure that transaction name has low cardinality.
5456// / If transaction name is unique for every call, per-transaction metrics will overflow metrics quota,
@@ -119,19 +121,45 @@ class TableClient final {
119121 );
120122 // / @}
121123
122- // / @name Transactions
124+ // / @name Transactions with retry
125+ // / @brief Execute a transactional function with automatic retries.
126+ // /
127+ // / The user-provided function receives a TxActor for executing queries
128+ // / and returns TxAction::kCommit or TxAction::kRollback. On transient
129+ // / errors the whole function is retried automatically.
130+ // /
131+ // / @code
132+ // / client.RetryTx("my_tx", {.retries = 3},
133+ // / [](ydb::TxActor& tx) {
134+ // / tx.Execute(query, "$id", 1);
135+ // / return ydb::TxAction::kCommit;
136+ // / });
137+ // / @endcode
138+ // /
139+ // / @{
140+ void RetryTx (utils::StringLiteral transaction_name, RetryTxSettings retry_settings, RetryTxFunction fn);
141+
142+ // / @warning Make sure that `transaction_name` has low cardinality.
143+ void RetryTx (DynamicTransactionName transaction_name, RetryTxSettings retry_settings, RetryTxFunction fn);
144+ // / @}
145+
146+ // / @name Transactions (deprecated)
123147 // / @brief Begin a transaction with the specified name. The settings are used
124148 // / for the `BEGIN` statement.
149+ // / @deprecated Use RetryTx instead for automatic retry support.
125150 // / @see ydb::Transaction
126151 // /
127152 // / @{
153+ [[deprecated(" Use RetryTx instead" )]]
128154 Transaction Begin (utils::StringLiteral transaction_name, OperationSettings settings = {});
129155
130156 // / @warning Make sure that `transaction_name` has low cardinality.
131157 // / If `transaction_name` is unique for every call, per-transaction metrics will overflow metrics quota,
132158 // / and metrics will become unusable.
159+ [[deprecated(" Use RetryTx instead" )]]
133160 Transaction Begin (DynamicTransactionName transaction_name, OperationSettings settings = {});
134161
162+ [[deprecated(" Use RetryTx instead" )]]
135163 Transaction Begin (utils::StringLiteral transaction_name, TransactionMode tx_mode);
136164 // / @}
137165
@@ -233,6 +261,8 @@ class TableClient final {
233261
234262private:
235263 friend class Transaction ;
264+ friend class TxActor ;
265+ template <typename Settings>
236266 friend struct impl ::RequestContext;
237267
238268 std::string JoinDbPath (std::string_view path) const ;
@@ -251,7 +281,7 @@ class TableClient final {
251281 // (TTableClient&, const std::string& full_path, const Settings&)
252282 // -> NThreading::TFuture<T>
253283 // ExecuteSchemeQueryImpl -> T
254- template <typename QuerySettings, typename Func>
284+ template <typename FuncResult, typename QuerySettings, typename Func>
255285 auto ExecuteWithPathImpl (
256286 std::string_view path,
257287 std::string_view operation_name,
0 commit comments