diff options
author | ilnaz <ilnaz@ydb.tech> | 2022-12-07 16:59:54 +0300 |
---|---|---|
committer | ilnaz <ilnaz@ydb.tech> | 2022-12-07 16:59:54 +0300 |
commit | 16d51715c1fec430a7c77ae6f569a202dc1ae12e (patch) | |
tree | 8b102371caa4427dedcd97f38fc7d20b83399ae6 | |
parent | e89ac12e6f29ea9d4732cd0089a16fead128cff8 (diff) | |
download | ydb-16d51715c1fec430a7c77ae6f569a202dc1ae12e.tar.gz |
RetentionPeriod in cpp sdk
-rw-r--r-- | ydb/public/sdk/cpp/client/ydb_table/table.cpp | 20 | ||||
-rw-r--r-- | ydb/public/sdk/cpp/client/ydb_table/table.h | 4 |
2 files changed, 22 insertions, 2 deletions
diff --git a/ydb/public/sdk/cpp/client/ydb_table/table.cpp b/ydb/public/sdk/cpp/client/ydb_table/table.cpp index e26310af5e..ca42ef69ee 100644 --- a/ydb/public/sdk/cpp/client/ydb_table/table.cpp +++ b/ydb/public/sdk/cpp/client/ydb_table/table.cpp @@ -4400,6 +4400,11 @@ TChangefeedDescription& TChangefeedDescription::WithVirtualTimestamps() { return *this; } +TChangefeedDescription& TChangefeedDescription::WithRetentionPeriod(const TDuration& value) { + RetentionPeriod_ = value; + return *this; +} + const TString& TChangefeedDescription::GetName() const { return Name_; } @@ -4489,6 +4494,12 @@ void TChangefeedDescription::SerializeTo(Ydb::Table::Changefeed& proto) const { case EChangefeedFormat::Unknown: break; } + + if (RetentionPeriod_) { + auto& retention = *proto.mutable_retention_period(); + retention.set_seconds(RetentionPeriod_->Seconds()); + retention.set_nanos(RetentionPeriod_->NanoSecondsOfSecond()); + } } TString TChangefeedDescription::ToString() const { @@ -4502,8 +4513,13 @@ void TChangefeedDescription::Out(IOutputStream& o) const { o << "{ name: \"" << Name_ << "\"" << ", mode: " << Mode_ << "" << ", format: " << Format_ << "" - << ", virtual_timestamps: " << (VirtualTimestamps_ ? "on": "off") << "" - << " }"; + << ", virtual_timestamps: " << (VirtualTimestamps_ ? "on": "off") << ""; + + if (RetentionPeriod_) { + o << ", retention_period: " << *RetentionPeriod_; + } + + o << " }"; } bool operator==(const TChangefeedDescription& lhs, const TChangefeedDescription& rhs) { diff --git a/ydb/public/sdk/cpp/client/ydb_table/table.h b/ydb/public/sdk/cpp/client/ydb_table/table.h index 676de85169..fd0908e13a 100644 --- a/ydb/public/sdk/cpp/client/ydb_table/table.h +++ b/ydb/public/sdk/cpp/client/ydb_table/table.h @@ -201,7 +201,10 @@ class TChangefeedDescription { public: TChangefeedDescription(const TString& name, EChangefeedMode mode, EChangefeedFormat format); + // Enable virtual timestamps TChangefeedDescription& WithVirtualTimestamps(); + // Customise retention period of underlying topic (24h by default). + TChangefeedDescription& WithRetentionPeriod(const TDuration& value); const TString& GetName() const; EChangefeedMode GetMode() const; @@ -224,6 +227,7 @@ private: EChangefeedMode Mode_; EChangefeedFormat Format_; bool VirtualTimestamps_ = false; + std::optional<TDuration> RetentionPeriod_; }; bool operator==(const TChangefeedDescription& lhs, const TChangefeedDescription& rhs); |