Skip to content

Commit

Permalink
Moved commit "Backup changefeed configurations (tools dump)" from ydb…
Browse files Browse the repository at this point in the history
… repo
  • Loading branch information
stanislav-shchetinin authored and Gazizonoki committed Dec 13, 2024
1 parent 6c86956 commit 22f7e87
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
4 changes: 4 additions & 0 deletions include/ydb-cpp-sdk/client/table/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,13 @@ class TChangefeedDescription {
const std::optional<TInitialScanProgress>& GetInitialScanProgress() const;

void SerializeTo(Ydb::Table::Changefeed& proto) const;
void SerializeTo(Ydb::Table::ChangefeedDescription& proto) const;
std::string ToString() const;
void Out(IOutputStream& o) const;

template <typename TProto>
void SerializeCommonFields(TProto& proto) const;

private:
explicit TChangefeedDescription(const Ydb::Table::Changefeed& proto);
explicit TChangefeedDescription(const Ydb::Table::ChangefeedDescription& proto);
Expand Down
31 changes: 27 additions & 4 deletions src/client/table/table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2817,10 +2817,10 @@ TChangefeedDescription TChangefeedDescription::FromProto(const TProto& proto) {
return ret;
}

void TChangefeedDescription::SerializeTo(Ydb::Table::Changefeed& proto) const {
template <typename TProto>
void TChangefeedDescription::SerializeCommonFields(TProto& proto) const {
proto.set_name(TStringType{Name_});
proto.set_virtual_timestamps(VirtualTimestamps_);
proto.set_initial_scan(InitialScan_);
proto.set_aws_region(TStringType{AwsRegion_});

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

for (const auto& [key, value] : Attributes_) {
(*proto.mutable_attributes())[key] = value;
}
}

void TChangefeedDescription::SerializeTo(Ydb::Table::Changefeed& proto) const {
SerializeCommonFields(proto);
proto.set_initial_scan(InitialScan_);

if (RetentionPeriod_) {
SetDuration(*RetentionPeriod_, *proto.mutable_retention_period());
}
}

for (const auto& [key, value] : Attributes_) {
(*proto.mutable_attributes())[key] = value;
void TChangefeedDescription::SerializeTo(Ydb::Table::ChangefeedDescription& proto) const {
SerializeCommonFields(proto);

switch (State_) {
case EChangefeedState::Enabled:
proto.set_state(Ydb::Table::ChangefeedDescription_State::ChangefeedDescription_State_STATE_ENABLED);
break;
case EChangefeedState::Disabled:
proto.set_state(Ydb::Table::ChangefeedDescription_State::ChangefeedDescription_State_STATE_DISABLED);
break;
case EChangefeedState::InitialScan:
proto.set_state(Ydb::Table::ChangefeedDescription_State::ChangefeedDescription_State_STATE_INITIAL_SCAN);
break;
case EChangefeedState::Unknown:
break;
}
}

Expand Down

0 comments on commit 22f7e87

Please sign in to comment.