5
5
#include < ydb/core/fq/libs/row_dispatcher/events/data_plane.h>
6
6
#include < ydb/core/fq/libs/row_dispatcher/format_handler/format_handler.h>
7
7
#include < ydb/core/protos/config.pb.h>
8
-
9
8
#include < ydb/library/actors/core/actor_bootstrapped.h>
10
9
#include < ydb/library/actors/core/hfunc.h>
11
10
#include < ydb/library/yql/dq/actors/dq.h>
12
-
11
+ # include < ydb/library/yql/providers/pq/common/pq_events_processor.h >
13
12
#include < ydb/public/sdk/cpp/adapters/issue/issue.h>
14
-
15
13
#include < ydb/public/sdk/cpp/include/ydb-cpp-sdk/client/topic/client.h>
16
14
17
15
#include < util/generic/queue.h>
@@ -62,6 +60,7 @@ struct TEvPrivate {
62
60
EvCreateSession,
63
61
EvSendStatistic,
64
62
EvReconnectSession,
63
+ EvExecuteTopicEvent,
65
64
EvEnd
66
65
};
67
66
static_assert (EvEnd < EventSpaceEnd(TEvents::ES_PRIVATE), " expect EvEnd < EventSpaceEnd(TEvents::ES_PRIVATE)" );
@@ -71,13 +70,16 @@ struct TEvPrivate {
71
70
struct TEvCreateSession : public TEventLocal <TEvCreateSession, EvCreateSession> {};
72
71
struct TEvSendStatistic : public TEventLocal <TEvSendStatistic, EvSendStatistic> {};
73
72
struct TEvReconnectSession : public TEventLocal <TEvReconnectSession, EvReconnectSession> {};
73
+ struct TEvExecuteTopicEvent : public NYql ::TTopicEventBase<TEvExecuteTopicEvent, EvExecuteTopicEvent> {
74
+ using TTopicEventBase::TTopicEventBase;
75
+ };
74
76
};
75
77
76
78
constexpr ui64 SendStatisticPeriodSec = 2 ;
77
79
constexpr ui64 MaxHandledEventsCount = 1000 ;
78
80
constexpr ui64 MaxHandledEventsSize = 1000000 ;
79
81
80
- class TTopicSession : public TActorBootstrapped <TTopicSession> {
82
+ class TTopicSession : public TActorBootstrapped <TTopicSession>, NYql::TTopicEventProcessor<TEvPrivate::TEvExecuteTopicEvent> {
81
83
private:
82
84
using TBase = TActorBootstrapped<TTopicSession>;
83
85
@@ -315,7 +317,7 @@ class TTopicSession : public TActorBootstrapped<TTopicSession> {
315
317
[[maybe_unused]] static constexpr char ActorName[] = " FQ_ROW_DISPATCHER_SESSION" ;
316
318
317
319
private:
318
- NYdb::NTopic::TTopicClientSettings GetTopicClientSettings (bool useSsl) const ;
320
+ NYdb::NTopic::TTopicClientSettings GetTopicClientSettings (bool useSsl);
319
321
NYql::ITopicClient& GetTopicClient (bool useSsl);
320
322
NYdb::NTopic::TReadSessionSettings GetReadSessionSettings (const TString& consumerName) const ;
321
323
void CreateTopicSession ();
@@ -351,6 +353,7 @@ class TTopicSession : public TActorBootstrapped<TTopicSession> {
351
353
private:
352
354
353
355
STRICT_STFUNC_EXC (StateFunc,
356
+ hFunc (TEvPrivate::TEvExecuteTopicEvent, HandleTopicEvent);
354
357
hFunc (NFq::TEvPrivate::TEvPqEventsReady, Handle);
355
358
hFunc (NFq::TEvPrivate::TEvCreateSession, Handle);
356
359
hFunc (NFq::TEvPrivate::TEvSendStatistic, Handle);
@@ -364,6 +367,7 @@ class TTopicSession : public TActorBootstrapped<TTopicSession> {
364
367
365
368
STRICT_STFUNC_EXC(ErrorState,
366
369
cFunc (TEvents::TEvPoisonPill::EventType, PassAway);
370
+ hFunc (TEvPrivate::TEvExecuteTopicEvent, HandleTopicEvent);
367
371
IgnoreFunc (NFq::TEvPrivate::TEvPqEventsReady);
368
372
IgnoreFunc (NFq::TEvPrivate::TEvCreateSession);
369
373
IgnoreFunc (TEvRowDispatcher::TEvGetNextBatch);
@@ -427,6 +431,7 @@ void TTopicSession::PassAway() {
427
431
428
432
void TTopicSession::SubscribeOnNextEvent () {
429
433
if (!ReadSession || IsWaitingEvents) {
434
+ LOG_ROW_DISPATCHER_TRACE (" Skip SubscribeOnNextEvent, has ReadSession: " << (ReadSession ? " true" : " false" ) << " , IsWaitingEvents: " << IsWaitingEvents);
430
435
return ;
431
436
}
432
437
@@ -445,12 +450,16 @@ void TTopicSession::SubscribeOnNextEvent() {
445
450
});
446
451
}
447
452
448
- NYdb::NTopic::TTopicClientSettings TTopicSession::GetTopicClientSettings (bool useSsl) const {
449
- return PqGateway->GetTopicClientSettings ()
450
- .Database (Database)
453
+ NYdb::NTopic::TTopicClientSettings TTopicSession::GetTopicClientSettings (bool useSsl) {
454
+ auto opts = PqGateway->GetTopicClientSettings ();
455
+ SetupTopicClientSettings (ActorContext ().ActorSystem (), SelfId (), opts);
456
+
457
+ opts.Database (Database)
451
458
.DiscoveryEndpoint (Endpoint)
452
459
.SslCredentials (NYdb::TSslCredentials (useSsl))
453
460
.CredentialsProviderFactory (CredentialsProviderFactory);
461
+
462
+ return opts;
454
463
}
455
464
456
465
NYql::ITopicClient& TTopicSession::GetTopicClient (bool useSsl) {
@@ -982,7 +991,7 @@ void TTopicSession::RefreshParsers() {
982
991
}
983
992
}
984
993
985
- } // anonymous namespace
994
+ } // anonymous namespace
986
995
987
996
// //////////////////////////////////////////////////////////////////////////////
988
997
@@ -1005,4 +1014,4 @@ std::unique_ptr<IActor> NewTopicSession(
1005
1014
return std::unique_ptr<IActor>(new TTopicSession (readGroup, topicPath, endpoint, database, config, functionRegistry, rowDispatcherActorId, compileServiceActorId, partitionId, std::move (driver), credentialsProviderFactory, counters, countersRoot, pqGateway, maxBufferSize));
1006
1015
}
1007
1016
1008
- } // namespace NFq
1017
+ } // namespace NFq
0 commit comments