Skip to content

Commit 22f7e87

Browse files
stanislav-shchetininGazizonoki
authored andcommitted
Moved commit "Backup changefeed configurations (tools dump)" from ydb repo
1 parent 6c86956 commit 22f7e87

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

include/ydb-cpp-sdk/client/table/table.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,13 @@ class TChangefeedDescription {
395395
const std::optional<TInitialScanProgress>& GetInitialScanProgress() const;
396396

397397
void SerializeTo(Ydb::Table::Changefeed& proto) const;
398+
void SerializeTo(Ydb::Table::ChangefeedDescription& proto) const;
398399
std::string ToString() const;
399400
void Out(IOutputStream& o) const;
400401

402+
template <typename TProto>
403+
void SerializeCommonFields(TProto& proto) const;
404+
401405
private:
402406
explicit TChangefeedDescription(const Ydb::Table::Changefeed& proto);
403407
explicit TChangefeedDescription(const Ydb::Table::ChangefeedDescription& proto);

src/client/table/table.cpp

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2817,10 +2817,10 @@ TChangefeedDescription TChangefeedDescription::FromProto(const TProto& proto) {
28172817
return ret;
28182818
}
28192819

2820-
void TChangefeedDescription::SerializeTo(Ydb::Table::Changefeed& proto) const {
2820+
template <typename TProto>
2821+
void TChangefeedDescription::SerializeCommonFields(TProto& proto) const {
28212822
proto.set_name(TStringType{Name_});
28222823
proto.set_virtual_timestamps(VirtualTimestamps_);
2823-
proto.set_initial_scan(InitialScan_);
28242824
proto.set_aws_region(TStringType{AwsRegion_});
28252825

28262826
switch (Mode_) {
@@ -2861,12 +2861,35 @@ void TChangefeedDescription::SerializeTo(Ydb::Table::Changefeed& proto) const {
28612861
SetDuration(*ResolvedTimestamps_, *proto.mutable_resolved_timestamps_interval());
28622862
}
28632863

2864+
for (const auto& [key, value] : Attributes_) {
2865+
(*proto.mutable_attributes())[key] = value;
2866+
}
2867+
}
2868+
2869+
void TChangefeedDescription::SerializeTo(Ydb::Table::Changefeed& proto) const {
2870+
SerializeCommonFields(proto);
2871+
proto.set_initial_scan(InitialScan_);
2872+
28642873
if (RetentionPeriod_) {
28652874
SetDuration(*RetentionPeriod_, *proto.mutable_retention_period());
28662875
}
2876+
}
28672877

2868-
for (const auto& [key, value] : Attributes_) {
2869-
(*proto.mutable_attributes())[key] = value;
2878+
void TChangefeedDescription::SerializeTo(Ydb::Table::ChangefeedDescription& proto) const {
2879+
SerializeCommonFields(proto);
2880+
2881+
switch (State_) {
2882+
case EChangefeedState::Enabled:
2883+
proto.set_state(Ydb::Table::ChangefeedDescription_State::ChangefeedDescription_State_STATE_ENABLED);
2884+
break;
2885+
case EChangefeedState::Disabled:
2886+
proto.set_state(Ydb::Table::ChangefeedDescription_State::ChangefeedDescription_State_STATE_DISABLED);
2887+
break;
2888+
case EChangefeedState::InitialScan:
2889+
proto.set_state(Ydb::Table::ChangefeedDescription_State::ChangefeedDescription_State_STATE_INITIAL_SCAN);
2890+
break;
2891+
case EChangefeedState::Unknown:
2892+
break;
28702893
}
28712894
}
28722895

0 commit comments

Comments
 (0)