Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify '__async_replication' attr #3056

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions ydb/core/tx/replication/controller/stream_creator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@
#include <ydb/library/actors/core/actor_bootstrapped.h>
#include <ydb/library/actors/core/hfunc.h>

#include <library/cpp/json/json_writer.h>

#include <util/string/cast.h>

namespace NKikimr::NReplication::NController {

class TStreamCreator: public TActorBootstrapped<TStreamCreator> {
static NYdb::NTable::TChangefeedDescription MakeChangefeed(const TString& name) {
static NYdb::NTable::TChangefeedDescription MakeChangefeed(const TString& name, const NJson::TJsonMap& attrs) {
using namespace NYdb::NTable;
return TChangefeedDescription(name, EChangefeedMode::Updates, EChangefeedFormat::Json)
.WithInitialScan();
.WithInitialScan()
.AddAttribute("__async_replication", NJson::WriteJson(attrs, false));
}

void CreateStream() {
Expand Down Expand Up @@ -117,14 +122,18 @@ class TStreamCreator: public TActorBootstrapped<TStreamCreator> {
ui64 tid,
TReplication::ETargetKind kind,
const TString& srcPath,
const TString& dstPath,
const TString& streamName)
: Parent(parent)
, YdbProxy(proxy)
, ReplicationId(rid)
, TargetId(tid)
, Kind(kind)
, SrcPath(srcPath)
, Changefeed(MakeChangefeed(streamName))
, Changefeed(MakeChangefeed(streamName, NJson::TJsonMap{
{"path", dstPath},
{"id", ToString(rid)},
}))
, LogPrefix("StreamCreator", ReplicationId, TargetId)
{
}
Expand Down Expand Up @@ -155,13 +164,14 @@ IActor* CreateStreamCreator(TReplication::TPtr replication, ui64 targetId, const
const auto* target = replication->FindTarget(targetId);
Y_ABORT_UNLESS(target);
return CreateStreamCreator(ctx.SelfID, replication->GetYdbProxy(),
replication->GetId(), target->GetId(), target->GetKind(), target->GetSrcPath(), target->GetStreamName());
replication->GetId(), target->GetId(), target->GetKind(),
target->GetSrcPath(), target->GetDstPath(), target->GetStreamName());
}

IActor* CreateStreamCreator(const TActorId& parent, const TActorId& proxy, ui64 rid, ui64 tid,
TReplication::ETargetKind kind, const TString& srcPath, const TString& streamName)
TReplication::ETargetKind kind, const TString& srcPath, const TString& dstPath, const TString& streamName)
{
return new TStreamCreator(parent, proxy, rid, tid, kind, srcPath, streamName);
return new TStreamCreator(parent, proxy, rid, tid, kind, srcPath, dstPath, streamName);
}

}
2 changes: 1 addition & 1 deletion ydb/core/tx/replication/controller/stream_creator.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ namespace NKikimr::NReplication::NController {

IActor* CreateStreamCreator(TReplication::TPtr replication, ui64 targetId, const TActorContext& ctx);
IActor* CreateStreamCreator(const TActorId& parent, const TActorId& proxy, ui64 rid, ui64 tid,
TReplication::ETargetKind kind, const TString& srcPath, const TString& streamName);
TReplication::ETargetKind kind, const TString& srcPath, const TString& dstPath, const TString& streamName);

}
1 change: 1 addition & 0 deletions ydb/core/tx/replication/controller/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ PEERDIR(
ydb/core/tx/replication/ydb_proxy
ydb/core/util
ydb/core/ydb_convert
library/cpp/json
)

SRCS(
Expand Down
Loading