Skip to content

Commit 3d1ee2a

Browse files
authored
(refactoring) Pass replication object to Progress() instead of a bunch of arguments (#2766)
1 parent c3a49ab commit 3d1ee2a

File tree

6 files changed

+22
-12
lines changed

6 files changed

+22
-12
lines changed

ydb/core/tx/replication/controller/replication.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ class TReplication::TImpl {
5151
}
5252
}
5353

54-
void ProgressTargets(const TActorContext& ctx) {
54+
void ProgressTargets(TReplication::TPtr self, const TActorContext& ctx) {
5555
for (auto& [_, target] : Targets) {
56-
target->Progress(PathId.OwnerId, YdbProxy, ctx);
56+
target->Progress(self, ctx);
5757
}
5858
}
5959

@@ -89,7 +89,7 @@ class TReplication::TImpl {
8989
Targets.erase(id);
9090
}
9191

92-
void Progress(const TActorContext& ctx) {
92+
void Progress(TReplication::TPtr self, const TActorContext& ctx) {
9393
if (!YdbProxy) {
9494
THolder<IActor> ydbProxy;
9595
switch (Config.GetCredentialsCase()) {
@@ -118,13 +118,13 @@ class TReplication::TImpl {
118118
if (!Targets) {
119119
return DiscoverTargets(ctx);
120120
} else {
121-
return ProgressTargets(ctx);
121+
return ProgressTargets(self, ctx);
122122
}
123123
case EState::Removing:
124124
if (!Targets) {
125125
return (void)ctx.Send(ctx.SelfID, new TEvPrivate::TEvDropReplication(ReplicationId));
126126
} else {
127-
return ProgressTargets(ctx);
127+
return ProgressTargets(self, ctx);
128128
}
129129
case EState::Error:
130130
return;
@@ -211,7 +211,7 @@ void TReplication::RemoveTarget(ui64 id) {
211211
}
212212

213213
void TReplication::Progress(const TActorContext& ctx) {
214-
Impl->Progress(ctx);
214+
Impl->Progress(this, ctx);
215215
}
216216

217217
void TReplication::Shutdown(const TActorContext& ctx) {
@@ -226,6 +226,10 @@ const TPathId& TReplication::GetPathId() const {
226226
return Impl->PathId;
227227
}
228228

229+
const TActorId& TReplication::GetYdbProxy() const {
230+
return Impl->YdbProxy;
231+
}
232+
229233
void TReplication::SetState(EState state, TString issue) {
230234
Impl->SetState(state, issue);
231235
}

ydb/core/tx/replication/controller/replication.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class TReplication: public TSimpleRefCount<TReplication> {
6868
virtual const TString& GetIssue() const = 0;
6969
virtual void SetIssue(const TString& value) = 0;
7070

71-
virtual void Progress(ui64 schemeShardId, const TActorId& proxy, const TActorContext& ctx) = 0;
71+
virtual void Progress(TReplication::TPtr replication, const TActorContext& ctx) = 0;
7272
virtual void Shutdown(const TActorContext& ctx) = 0;
7373
};
7474

@@ -93,6 +93,7 @@ class TReplication: public TSimpleRefCount<TReplication> {
9393

9494
ui64 GetId() const;
9595
const TPathId& GetPathId() const;
96+
const TActorId& GetYdbProxy() const;
9697
void SetState(EState state, TString issue = {});
9798
EState GetState() const;
9899
const TString& GetIssue() const;

ydb/core/tx/replication/controller/target_base.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ ETargetKind TTargetBase::GetTargetKind() const {
8181
return Kind;
8282
}
8383

84-
void TTargetBase::Progress(ui64 schemeShardId, const TActorId& proxy, const TActorContext& ctx) {
84+
void TTargetBase::Progress(TReplication::TPtr replication, const TActorContext& ctx) {
85+
const auto schemeShardId = replication->GetPathId().OwnerId;
86+
const auto& proxy = replication->GetYdbProxy();
87+
8588
switch (DstState) {
8689
case EDstState::Creating:
8790
if (!DstCreator) {

ydb/core/tx/replication/controller/target_base.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class TTargetBase: public TReplication::ITarget {
3131
const TString& GetIssue() const override;
3232
void SetIssue(const TString& value) override;
3333

34-
void Progress(ui64 schemeShardId, const TActorId& proxy, const TActorContext& ctx) override;
34+
void Progress(TReplication::TPtr replication, const TActorContext& ctx) override;
3535
void Shutdown(const TActorContext& ctx) override;
3636

3737
protected:

ydb/core/tx/replication/controller/target_with_stream.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ namespace NKikimr::NReplication::NController {
99

1010
const TString ReplicationConsumerName = "replicationConsumer";
1111

12-
void TTargetWithStream::Progress(ui64 schemeShardId, const TActorId& proxy, const TActorContext& ctx) {
12+
void TTargetWithStream::Progress(TReplication::TPtr replication, const TActorContext& ctx) {
13+
const auto& proxy = replication->GetYdbProxy();
14+
1315
switch (GetStreamState()) {
1416
case EStreamState::Creating:
1517
if (GetStreamName().empty() && !NameAssignmentInProcess) {
@@ -32,7 +34,7 @@ void TTargetWithStream::Progress(ui64 schemeShardId, const TActorId& proxy, cons
3234
break;
3335
}
3436

35-
TTargetBase::Progress(schemeShardId, proxy, ctx);
37+
TTargetBase::Progress(replication, ctx);
3638
}
3739

3840
void TTargetWithStream::Shutdown(const TActorContext& ctx) {

ydb/core/tx/replication/controller/target_with_stream.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class TTargetWithStream: public TTargetBase {
1515
SetStreamState(EStreamState::Creating);
1616
}
1717

18-
void Progress(ui64 schemeShardId, const TActorId& proxy, const TActorContext& ctx) override;
18+
void Progress(TReplication::TPtr replication, const TActorContext& ctx) override;
1919
void Shutdown(const TActorContext& ctx) override;
2020

2121
private:

0 commit comments

Comments
 (0)