Skip to content

Commit edcad84

Browse files
committed
Moved commit "Add start and end times to Operations API" from ydb repo
1 parent a995392 commit edcad84

File tree

4 files changed

+31
-12
lines changed

4 files changed

+31
-12
lines changed

include/ydb-cpp-sdk/client/types/operation/operation.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <library/cpp/threading/future/future.h>
66

77
#include <google/protobuf/stubs/status.h>
8+
#include <google/protobuf/timestamp.pb.h>
89
#include <google/protobuf/util/json_util.h>
910

1011
namespace Ydb {
@@ -31,6 +32,8 @@ class TOperation {
3132
const TOperationId& Id() const;
3233
bool Ready() const;
3334
const TStatus& Status() const;
35+
TInstant StartTime() const;
36+
TInstant EndTime() const;
3437

3538
std::string ToString() const;
3639
std::string ToJsonString() const;
@@ -46,4 +49,6 @@ class TOperation {
4649

4750
using TAsyncOperation = NThreading::TFuture<TOperation>;
4851

52+
TInstant ProtoTimestampToInstant(const google::protobuf::Timestamp& timestamp);
53+
4954
} // namespace NYdb

src/client/export/export.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ using namespace Ydb::Export;
2424
/// Common
2525
namespace {
2626

27-
TInstant ProtoTimestampToInstant(const google::protobuf::Timestamp& timestamp) {
28-
ui64 us = timestamp.seconds() * 1000000;
29-
us += timestamp.nanos() / 1000;
30-
return TInstant::MicroSeconds(us);
31-
}
32-
3327
std::vector<TExportItemProgress> ItemsProgressFromProto(const google::protobuf::RepeatedPtrField<ExportItemProgress>& proto) {
3428
std::vector<TExportItemProgress> result(proto.size());
3529

src/client/import/import.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ using namespace Ydb::Import;
1919
/// Common
2020
namespace {
2121

22-
TInstant ProtoTimestampToInstant(const google::protobuf::Timestamp& timestamp) {
23-
ui64 us = timestamp.seconds() * 1000000;
24-
us += timestamp.nanos() / 1000;
25-
return TInstant::MicroSeconds(us);
26-
}
27-
2822
std::vector<TImportItemProgress> ItemsProgressFromProto(const google::protobuf::RepeatedPtrField<Ydb::Import::ImportItemProgress>& proto) {
2923
std::vector<TImportItemProgress> result;
3024
result.reserve(proto.size());

src/client/types/operation/operation.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class TOperation::TImpl {
2121
: Id_(operation.id(), true /* allowEmpty */)
2222
, Status_(std::move(status))
2323
, Ready_(operation.ready())
24+
, StartTime_(ProtoTimestampToInstant(operation.start_time()))
25+
, EndTime_(ProtoTimestampToInstant(operation.end_time()))
2426
, Operation_(std::move(operation))
2527
{
2628
}
@@ -37,6 +39,14 @@ class TOperation::TImpl {
3739
return Status_;
3840
}
3941

42+
TInstant StartTime() const {
43+
return StartTime_;
44+
}
45+
46+
TInstant EndTime() const {
47+
return EndTime_;
48+
}
49+
4050
const Ydb::Operations::Operation& GetProto() const {
4151
return Operation_;
4252
}
@@ -45,6 +55,8 @@ class TOperation::TImpl {
4555
const TOperationId Id_;
4656
const TStatus Status_;
4757
const bool Ready_;
58+
const TInstant StartTime_;
59+
const TInstant EndTime_;
4860
const Ydb::Operations::Operation Operation_;
4961
};
5062

@@ -68,6 +80,14 @@ const TStatus& TOperation::Status() const {
6880
return Impl_->Status();
6981
}
7082

83+
TInstant TOperation::StartTime() const {
84+
return Impl_->StartTime();
85+
}
86+
87+
TInstant TOperation::EndTime() const {
88+
return Impl_->EndTime();
89+
}
90+
7191
std::string TOperation::ToString() const {
7292
TString result;
7393
TStringOutput out(result);
@@ -92,4 +112,10 @@ const Ydb::Operations::Operation& TOperation::GetProto() const {
92112
return Impl_->GetProto();
93113
}
94114

115+
TInstant ProtoTimestampToInstant(const google::protobuf::Timestamp& timestamp) {
116+
ui64 us = timestamp.seconds() * 1000000;
117+
us += timestamp.nanos() / 1000;
118+
return TInstant::MicroSeconds(us);
119+
}
120+
95121
} // namespace NYdb

0 commit comments

Comments
 (0)