Skip to content

Commit fd80112

Browse files
Improvements after review
1 parent 9b57613 commit fd80112

File tree

3 files changed

+14
-28
lines changed

3 files changed

+14
-28
lines changed

ydb/core/driver_lib/run/kikimr_services_initializers.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,6 +1723,8 @@ void TGRpcServicesInitializer::InitializeServices(NActors::TActorSystemSetup* se
17231723
desc->Ssl = kakfaConfig.HasSslCertificate();
17241724

17251725
desc->EndpointId = NGRpcService::KafkaEndpointId;
1726+
endpoints.push_back(std::move(desc));
1727+
17261728
}
17271729

17281730
for (auto &sx : config.GetExtEndpoints()) {
@@ -2773,13 +2775,11 @@ void TKafkaProxyServiceInitializer::InitializeServices(NActors::TActorSystemSetu
27732775
settings.CertificateFile = Config.GetKafkaProxyConfig().GetCert();
27742776
settings.PrivateKeyFile = Config.GetKafkaProxyConfig().GetKey();
27752777

2776-
if (Config.GetKafkaProxyConfig().GetEnableEndpointDiscovery()) {
2777-
setup->LocalServices.emplace_back(
2778-
NKafka::MakeKafkaDiscoveryCacheID(),
2779-
TActorSetupCmd(CreateDiscoveryCache(NGRpcService::KafkaEndpointId),
2780-
TMailboxType::HTSwap, appData->UserPoolId)
2781-
);
2782-
}
2778+
setup->LocalServices.emplace_back(
2779+
NKafka::MakeKafkaDiscoveryCacheID(),
2780+
TActorSetupCmd(CreateDiscoveryCache(NGRpcService::KafkaEndpointId),
2781+
TMailboxType::HTSwap, appData->UserPoolId)
2782+
);
27832783
setup->LocalServices.emplace_back(
27842784
TActorId(),
27852785
TActorSetupCmd(NKafka::CreateKafkaListener(MakePollerActorId(), settings, Config.GetKafkaProxyConfig(),

ydb/core/kafka_proxy/actors/kafka_metadata_actor.cpp

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ using namespace NKikimr::NGRpcProxy::V1;
1111

1212
NActors::IActor* CreateKafkaMetadataActor(const TContext::TPtr context,
1313
const ui64 correlationId,
14-
const TMessagePtr<TMetadataRequestData>& message) {
15-
return new TKafkaMetadataActor(context, correlationId, message);
14+
const TMessagePtr<TMetadataRequestData>& message,
15+
const TActorId& discoveryCacheActor) {
16+
return new TKafkaMetadataActor(context, correlationId, message, discoveryCacheActor);
1617
}
1718

1819
void TKafkaMetadataActor::Bootstrap(const TActorContext& ctx) {
@@ -23,10 +24,7 @@ void TKafkaMetadataActor::Bootstrap(const TActorContext& ctx) {
2324
if (WithProxy) {
2425
AddProxyNodeToBrokers();
2526
} else {
26-
if (Context->Config.GetEnableEndpointDiscovery())
27-
SendDiscoveryRequest();
28-
else
29-
RequestICNodeCache();
27+
SendDiscoveryRequest();
3028

3129
if (Message->Topics.size() == 0) {
3230
NeedCurrentNode = true;
@@ -42,10 +40,7 @@ void TKafkaMetadataActor::Bootstrap(const TActorContext& ctx) {
4240
}
4341

4442
void TKafkaMetadataActor::SendDiscoveryRequest() {
45-
if (!DiscoveryCacheActor) {
46-
OwnDiscoveryCache = true;
47-
DiscoveryCacheActor = Register(CreateDiscoveryCache(NGRpcService::KafkaEndpointId));
48-
}
43+
Y_VERIFY_DEBUG(DiscoveryCacheActor);
4944
PendingResponses++;
5045
Register(CreateDiscoverer(&MakeEndpointsBoardPath, Context->DatabasePath, SelfId(), DiscoveryCacheActor));
5146
}
@@ -270,6 +265,7 @@ void TKafkaMetadataActor::RespondIfRequired(const TActorContext& ctx) {
270265
return;
271266
}
272267
AddBroker(nodeIter->first, nodeIter->second.Host, nodeIter->second.Port);
268+
NeedCurrentNode = false;
273269
}
274270
while (!PendingTopicResponses.empty()) {
275271
auto& [index, ev] = *PendingTopicResponses.begin();
@@ -293,14 +289,6 @@ void TKafkaMetadataActor::RespondIfRequired(const TActorContext& ctx) {
293289
Respond();
294290
}
295291

296-
void TKafkaMetadataActor::Die(const TActorContext& ctx) {
297-
if (OwnDiscoveryCache) {
298-
Send(DiscoveryCacheActor, new TEvents::TEvPoison());
299-
OwnDiscoveryCache = false;
300-
}
301-
TActor::Die(ctx);
302-
}
303-
304292
TString TKafkaMetadataActor::LogPrefix() const {
305293
return TStringBuilder() << "TKafkaMetadataActor " << SelfId() << " ";
306294
}

ydb/core/kafka_proxy/actors/kafka_metadata_actor.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace NKafka {
1212
class TKafkaMetadataActor: public NActors::TActorBootstrapped<TKafkaMetadataActor> {
1313
public:
1414
TKafkaMetadataActor(const TContext::TPtr context, const ui64 correlationId, const TMessagePtr<TMetadataRequestData>& message,
15-
const TActorId& discoveryCacheActor = {})
15+
const TActorId& discoveryCacheActor)
1616
: Context(context)
1717
, CorrelationId(correlationId)
1818
, Message(message)
@@ -60,7 +60,6 @@ class TKafkaMetadataActor: public NActors::TActorBootstrapped<TKafkaMetadataActo
6060
}
6161

6262
TString LogPrefix() const;
63-
void Die(const TActorContext& ctx) override;
6463

6564
private:
6665
const TContext::TPtr Context;
@@ -76,7 +75,6 @@ class TKafkaMetadataActor: public NActors::TActorBootstrapped<TKafkaMetadataActo
7675
EKafkaErrors ErrorCode = EKafkaErrors::NONE_ERROR;
7776

7877
TActorId DiscoveryCacheActor;
79-
bool OwnDiscoveryCache = false;
8078
bool NeedCurrentNode = false;
8179
bool HaveError = false;
8280
bool FallbackToIcDiscovery = false;

0 commit comments

Comments
 (0)