1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#include "persqueue.h"
#include "grpc_pq_read.h"
#include "grpc_pq_write.h"
#include <ydb/core/base/appdata.h>
#include <ydb/core/base/counters.h>
namespace NKikimr {
namespace NGRpcService {
static const ui32 PersQueueWriteSessionsMaxCount = 1000000;
static const ui32 PersQueueReadSessionsMaxCount = 100000;
TGRpcPersQueueService::TGRpcPersQueueService(NActors::TActorSystem *system, TIntrusivePtr<NMonitoring::TDynamicCounters> counters, const NActors::TActorId& schemeCache)
: ActorSystem(system)
, Counters(counters)
, SchemeCache(schemeCache)
{ }
void TGRpcPersQueueService::InitService(grpc::ServerCompletionQueue *cq, NGrpc::TLoggerPtr) {
CQ = cq;
if (ActorSystem->AppData<TAppData>()->PQConfig.GetEnabled()) {
WriteService.reset(new NGRpcProxy::TPQWriteService(GetService(), CQ, ActorSystem, SchemeCache, Counters, PersQueueWriteSessionsMaxCount));
WriteService->InitClustersUpdater();
ReadService.reset(new NGRpcProxy::TPQReadService(this, CQ, ActorSystem, SchemeCache, Counters, PersQueueReadSessionsMaxCount));
SetupIncomingRequests();
}
}
void TGRpcPersQueueService::SetGlobalLimiterHandle(NGrpc::TGlobalLimiter* limiter) {
Limiter = limiter;
}
bool TGRpcPersQueueService::IncRequest() {
return Limiter->Inc();
}
void TGRpcPersQueueService::DecRequest() {
Limiter->Dec();
}
void TGRpcPersQueueService::SetupIncomingRequests() {
WriteService->SetupIncomingRequests();
ReadService->SetupIncomingRequests();
}
void TGRpcPersQueueService::StopService() noexcept {
TGrpcServiceBase::StopService();
if (WriteService.get() != nullptr) {
WriteService->StopService();
}
if (ReadService.get() != nullptr) {
ReadService->StopService();
}
}
} // namespace NGRpcService
} // namespace NKikimr
|