File tree Expand file tree Collapse file tree 3 files changed +31
-9
lines changed
yql/providers/generic/connector/libcpp Expand file tree Collapse file tree 3 files changed +31
-9
lines changed Original file line number Diff line number Diff line change @@ -141,15 +141,8 @@ void TChannelPool::GetStubsHolderLocked(
141
141
}
142
142
}
143
143
}
144
- TGRpcKeepAliveSocketMutator* mutator = nullptr ;
144
+ auto mutator = NImpl::CreateGRpcKeepAliveSocketMutator (TcpKeepAliveSettings_) ;
145
145
// will be destroyed inside grpc
146
- if (TcpKeepAliveSettings_.Enabled ) {
147
- mutator = new TGRpcKeepAliveSocketMutator (
148
- TcpKeepAliveSettings_.Idle ,
149
- TcpKeepAliveSettings_.Count ,
150
- TcpKeepAliveSettings_.Interval
151
- );
152
- }
153
146
cb (Pool_.emplace (channelId, CreateChannelInterface (config, mutator)).first ->second );
154
147
LastUsedQueue_.emplace (Pool_.at (channelId).GetLastUseTime (), channelId);
155
148
}
@@ -588,4 +581,16 @@ void TGRpcClientLow::ForgetContext(TContextImpl* context) {
588
581
}
589
582
}
590
583
584
+ grpc_socket_mutator* NImpl::CreateGRpcKeepAliveSocketMutator (const TTcpKeepAliveSettings& TcpKeepAliveSettings_) {
585
+ TGRpcKeepAliveSocketMutator* mutator = nullptr ;
586
+ if (TcpKeepAliveSettings_.Enabled ) {
587
+ mutator = new TGRpcKeepAliveSocketMutator (
588
+ TcpKeepAliveSettings_.Idle ,
589
+ TcpKeepAliveSettings_.Count ,
590
+ TcpKeepAliveSettings_.Interval
591
+ );
592
+ }
593
+ return mutator;
594
+ }
595
+
591
596
} // namespace NGRpc
Original file line number Diff line number Diff line change @@ -451,6 +451,10 @@ class IStreamRequestReadWriteProcessor : public IStreamRequestReadProcessor<TRes
451
451
452
452
class TGRpcKeepAliveSocketMutator ;
453
453
454
+ namespace NImpl {
455
+ grpc_socket_mutator* CreateGRpcKeepAliveSocketMutator (const TTcpKeepAliveSettings& TcpKeepAliveSettings_);
456
+ } // NImpl
457
+
454
458
// Class to hold stubs allocated on channel.
455
459
// It is poor documented part of grpc. See KIKIMR-6109 and comment to this commit
456
460
@@ -1386,6 +1390,13 @@ class TGRpcClientLow
1386
1390
return std::unique_ptr<TServiceConnection<TGRpcService>>(new TServiceConnection<TGRpcService>(CreateChannelInterface (config), this ));
1387
1391
}
1388
1392
1393
+ template <typename TGRpcService>
1394
+ std::unique_ptr<TServiceConnection<TGRpcService>> CreateGRpcServiceConnection (const TGRpcClientConfig& config, const TTcpKeepAliveSettings& keepAlive) {
1395
+ auto mutator = NImpl::CreateGRpcKeepAliveSocketMutator (keepAlive);
1396
+ // will be destroyed inside grpc
1397
+ return std::unique_ptr<TServiceConnection<TGRpcService>>(new TServiceConnection<TGRpcService>(CreateChannelInterface (config, mutator), this ));
1398
+ }
1399
+
1389
1400
template <typename TGRpcService>
1390
1401
std::unique_ptr<TServiceConnection<TGRpcService>> CreateGRpcServiceConnection (TStubsHolder& holder) {
1391
1402
return std::unique_ptr<TServiceConnection<TGRpcService>>(new TServiceConnection<TGRpcService>(holder, this ));
Original file line number Diff line number Diff line change @@ -44,7 +44,13 @@ namespace NYql::NConnector {
44
44
GrpcClient_ = std::make_unique<NYdbGrpc::TGRpcClientLow>();
45
45
46
46
// FIXME: is it OK to use single connection during the client lifetime?
47
- GrpcConnection_ = GrpcClient_->CreateGRpcServiceConnection <NApi::Connector>(GrpcConfig_);
47
+ GrpcConnection_ = GrpcClient_->CreateGRpcServiceConnection <NApi::Connector>(GrpcConfig_, NYdbGrpc::TTcpKeepAliveSettings {
48
+ // TODO configure hardcoded values
49
+ .Enabled = true ,
50
+ .Idle = 30 ,
51
+ .Count = 5 ,
52
+ .Interval = 10
53
+ });
48
54
}
49
55
50
56
virtual TDescribeTableAsyncResult DescribeTable (const NApi::TDescribeTableRequest& request) override {
You can’t perform that action at this time.
0 commit comments