ptupitsyn commented on a change in pull request #8836:
URL: https://github.com/apache/ignite/pull/8836#discussion_r584482528
##########
File path:
modules/platforms/cpp/thin-client/src/impl/cache/cache_client_impl.cpp
##########
@@ -101,274 +101,238 @@ namespace ignite
return channel;
}
- template<typename ReqT>
- void CacheClientImpl::checkTransactional(ReqT& req)
+ template<typename ReqT, typename RspT>
+ bool CacheClientImpl::TryProcessTransactional(ReqT& req, RspT&
rsp)
{
- SP_TransactionImpl activeTx = tx.Get()->GetCurrent();
+ TransactionImpl* activeTx = tx.Get()->GetCurrent().Get();
+
+ if (!activeTx)
+ return false;
- bool isUnderTx = activeTx.IsValid();
+ req.activeTx(true, activeTx->TxId());
- int32_t txId = isUnderTx ? activeTx.Get()->TxId() : 0;
+ SP_DataChannel channel = activeTx->GetChannel();
- req.activeTx(isUnderTx, txId);
+ channel.Get()->SyncMessage(req, rsp,
router.Get()->GetIoTimeout());
+
+ if (rsp.GetStatus() != ResponseStatus::SUCCESS)
+ throw IgniteError(IgniteError::IGNITE_ERR_CACHE,
rsp.GetError().c_str());
+
+ return true;
}
void CacheClientImpl::Put(const WritableKey& key, const
Writable& value)
{
Cache2ValueRequest<RequestType::CACHE_PUT> req(id, binary,
key, value);
-
- checkTransactional(req);
-
Response rsp;
- SyncCacheKeyMessage(key, req, rsp);
+ if (!TryProcessTransactional(req, rsp))
Review comment:
The condition `if (!TryProcessTransactional(...))
SyncCacheKeyMessage(...)` is duplicated a lot, I think we can move this logic
into `SyncCacheKeyMessage` / `SyncMessage`. Should be less error-prone as well
if we add new operations.
##########
File path: modules/platforms/cpp/thin-client/CMakeLists.txt
##########
@@ -34,6 +34,7 @@ set(SOURCES src/impl/data_channel.cpp
src/impl/message.cpp
src/impl/cache/cache_client_proxy.cpp
src/impl/cache/cache_client_impl.cpp
+ src/impl/transactions/transaction_impl.cpp
Review comment:
Nitpick: indent, tabs vs spaces?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]